Good afternoon,
First I have to say that I have been trying to implement the SMOOTH tile-based movement for five days (I'm trying to add it using clean code).
For the moment, I have implemented a "teleportation movement" where the sprite moves to the next (up, down, left or right) tile without walking, so it goes 16px automatically. When I say next, if I maintain pressed the button it can be more than one tile. Here goes the GIF:
This is done in the GameState, that represents the state where the game occurs. The most important classes are:
Source/World: this contains the elements that you see on the screen: the NPCs (for the moment one).
Source/TileMap: this builds and renders the tilemap that you see in the gif.
Source/Npc: this is the guy you see on the image.
Source/Player: this sends the Player output to the Npc via a command Queue.
Github:
https://github.com/lazaro92/fantasy-maker/tree/developMy idea to implement the smooth movement is to move the npc via the Player class, in the Player NpcMover struct. While I move the player, in the World class I would like to check if the movement has been completed (so the npc has moved all the exact16px, not one less or more).
Do you have any ideas or examples of a smooth tile-based movement? It would help me a lot
----------------
After I implement the movement, I will start with collision detection, so the idea after movement will be that if I press a key, before the Npc starts to move the system will check if the destination tile is available to move in.