1
General discussions / Re: Help with Book (SFML Game Development By Example)
« on: December 01, 2019, 01:48:51 am »
What you have done looks correct...let me see if this helps...
The Tile Map has no concept of a "position" itself. It's merely a buffer of Tile Data. When it is drawn to the screen, there is predefined Sheet data that provides the tile position and tile size to the Sprite when it's drawn.
So here is what I propose:
1. Get the players position via the ECS
2. Determine the players Tile Coordinates based on the Sheet sizes
(You have this so far)
3. Determine the tile you want to move to.
4. Convert that tile to the game position (x * TileSize, y * TileSize)
5. Set a Target for the player to Move To (Implementation is up to you but you will probably need a Component for Targeting, an Entity State to indicate movement is happening (I think it already exist), and an Entity Message to notify the State system that Target Movement is occurring. The Movement System will need to update the Mover automatically while the Target is set.
Hope this helps.
The Tile Map has no concept of a "position" itself. It's merely a buffer of Tile Data. When it is drawn to the screen, there is predefined Sheet data that provides the tile position and tile size to the Sprite when it's drawn.
So here is what I propose:
1. Get the players position via the ECS
2. Determine the players Tile Coordinates based on the Sheet sizes
(You have this so far)
3. Determine the tile you want to move to.
4. Convert that tile to the game position (x * TileSize, y * TileSize)
5. Set a Target for the player to Move To (Implementation is up to you but you will probably need a Component for Targeting, an Entity State to indicate movement is happening (I think it already exist), and an Entity Message to notify the State system that Target Movement is occurring. The Movement System will need to update the Mover automatically while the Target is set.
Hope this helps.