I've been working on a top down 2d game and the character moves freely around the map, like zelda link to the past.
How would you model the data structure for such a game in order to implement pathfinding, astar, etc.
As far I understood one could go with this approach:
Tile {
sprite,
walkable,
position,
}
Board {
width
height
tiles: Tile[]
}
In a board of 5x5 there will be a sprite rendered for each tile. But here comes the problem:
The player is at position (+1,+1). Now it moves to the right side (+2,+1). This will mean that the player is moved immediately from one tile to another. So, we could make the player move pixel by pixel. How would you translate this back to the grid position?
If player moves pixel by pixel (using floating point instead of integers) and is at position (1.5,1),doest it means we need a separated data to store player position and later on round its current position (1.5, 1) to find its current cell in the grid?
I'm kind lost in this subject, i would love if you could share some thoughts on it, articles, videos, books, etc.
Thanks!