Detecting tile with height in isometric game

Posted by Carlos Navarro on Game Development See other posts from Game Development or by Carlos Navarro
Published on 2013-07-31T12:24:09Z Indexed on 2013/10/29 22:22 UTC
Read the original article Hit count: 219

Filed under:
|

I'm trying to create an isometric tile-based game (for iPhone) and I'm having trouble with height in tiles.

What I currently do (without heights) is apply some mathematic transformations to my 2D-matrix (which represent the tiles) so that I know where in the screen (x,y) should I place the isometric tile. Then, when the user clicks somewhere in the screen, I take that values and pass them through a function (kind of f^-1) to get which tile it belongs to.

This works perfectly. My problem is: imagine that I want some tiles to have a different height from others. In order to draw the tile itself its pretty simple, since the z-coordinate has no transformation in the isometric approach used in games (z'=z). BUT what if I want to calculate the tile coordinate (defined by X-tile and Y-tile) from the touch coordinates (x,y)? Any guess?

© Game Development or respective owner

Related posts about tiles

Related posts about isometric