You can indeed solve this with a little maths.
In my isometric games, I use the following code to calculate where to draw a given tile:
1 2
| int screenx = (int)(TILE_WIDTH * (tilex - tiley)/2.0); int screeny = (int)(TILE_HEIGHT * (tilex + tiley)/2.0); |
- screenx and screeny are the position on screen
- tilex and tiley are the tile position in the game world
- in your case, TILE_WIDTH = 64 and TILE_HEIGHT = 32
- some games may include a camera offset, but in principal they all work the same way
To determine which tile is selected on screen, you can use simultaneous equations to find tilex and tiley. Basically, make tilex the subject of the first equation, and tiley the subject of the second. I can explain this bit in more detail if you like...
Solving the simultaneous equations results in the following code:
1 2
| int tilex = (int)(screenx/TILE_WIDTH + screeny/TILE_HEIGHT); int tiley = (int)(screeny/TILE_HEIGHT - screenx/TILE_WIDTH); |