Repository navigation
Player Camera
In order to facilitate a larger map, the camera was changed from being fixed to a tracking and following the player. Additionally the cameras has its own speed, allowing the camera to smoothly follow the player for a better gameplay experience. On top of this the camera will not cross the "Wall" boundaries of a room.
The camera also works off any entity as the implementation uses the entities position, future additions can use this to follow any other entity.
The room entity should add FollowingCameraComponent to their components. Additionally for the component to work the camera, and either a target entity, or a goal vector has to be added to the component. If the camera is not given to the component it will not do anything.
player.getComponent(FollowingCameraComponent.class).setCamera(render.getCamera);
player.getComponent(FollowingCameraComponent.class).setTarget(player);To temporarily stop the camera from following the player, remove the target
player.getComponent(FollowingCameraComponent.class).removeTarget();
// camera is no longer following the player
// ...
player.getComponent(FollowingCameraComponent.class).setTarget(player);
// camera resumes following the player
// ...Every update, the component takes the goal position (if there is a target entity, that entities position is its goal), calculates how much to move based on its speed, then sets the camera's (provided by the renderer) position which the render updates for the user to see on screen.
...