Tiles and animating movement between them?
Posted: Thu May 20, 2021 11:41 pm
My project has tiles and all positioning and movement is in discrete x/y values so that everything happens in the middle of the tile. This is a chosen style/aesthetic plus a coding convenience.
I now need to work out movement and animation between tiles where an object/sprite is between tiles and not aligned to my tidy x/y grid. Not only that, collision detection and interactions might happen during these transitions.
For example, a wolf is on tile (1,1) and needs to move to (2,2). I'm guessing the (1,1) needs to be converted to a graphics/screen x/y for drawing purposes. I'm then thinking vectors and vector math can move the sprite to the destination. At that point, it is 'safely' centred on the tile and can once again exist in the tiled world of (2,2).
An additional challenge is having the player target the wolf because it won't be in any one tile so I guess the 'targeting cursor' needs to free roam between tiles.
If the player shoots towards the wolf then I guess normal bounding box comes into play, again, abandoning the tile system.
Am I thinking about this the right way?
I now need to work out movement and animation between tiles where an object/sprite is between tiles and not aligned to my tidy x/y grid. Not only that, collision detection and interactions might happen during these transitions.
For example, a wolf is on tile (1,1) and needs to move to (2,2). I'm guessing the (1,1) needs to be converted to a graphics/screen x/y for drawing purposes. I'm then thinking vectors and vector math can move the sprite to the destination. At that point, it is 'safely' centred on the tile and can once again exist in the tiled world of (2,2).
An additional challenge is having the player target the wolf because it won't be in any one tile so I guess the 'targeting cursor' needs to free roam between tiles.
If the player shoots towards the wolf then I guess normal bounding box comes into play, again, abandoning the tile system.
Am I thinking about this the right way?