I'm not entirely certain I understand your question but I think you're asking how you would get the camera to follow the player as he moves.
There's probably a number of different ways to approach this problem. In an entity component system might create some sort of
CameraFollowSystem similar to how the
PlayerMovementSystem works. Although, the design is really up to you depending on how you want your game to work.
The absolute simplest way to get this working is to pass the
_camera into the constructor of the
PlayerMovementSystem like so:
PlayerMovementSystem you'd change the constructor to look like this:
private readonly Camera2D _camera;
public PlayerMovementSystem(Camera2D camera)
_camera = camera;
Then finally in the
Update method you add your
public override void Update(GameTime gameTime)
if(_playerEntity == null)
And that's it.
At this point, the camera will follow the player in a kind of rough prototype kind of way. You'd have to think about how to deal with the camera going outside the bounds of the map and maybe you'd want to implement some sort of tweening for camera movement perhaps.