Let’s say you have a tile based game such as “Snake” (also known as “Nibbles”) or this game where you can only “be” on one tile at a time. (compared to, say, the old Mario games where the level may be composed of tiles, but you can have an “x” and “y” position that does not snap to the nearest tile and you can stand wherever you want)
If you wanted to move to the tile to your right, you could instantly “jump” over to the right tile, or you could take a certain amount of time to “move” toward the right until you land on the next tile (like PacMan).
Assuming you can’t move diagonally, and only move between two adjacent tiles, how would you keep track of this “transition between two tiles” in code? (keeping track of “global” x and y positions feels dirty if you are sitting on a grid and forced to “stick” to the grid when you stop moving)
In the transition, which tile should you consider the player to be “on”?
Does anyone know of a working game with open code that uses these types of mechanics that I can study from?
I run into this problem quite a bit, and usually hack together some ugly solution for which I should be flogged. But I’m looking for something more “elegant”.