• Advertisement
Sign in to follow this  

Staggered Isometric - Screen To Tile

This topic is 3738 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi! Everyone, I'm working on a staggered isometric engine. Where tiles are like this... [0,0][0,1][0,2][0,3] [1,0][1,1][1,2][1,3] [2,0][2,1][2,2][2,3] [3,0][3,1][3,2][3,3] and of course tiles are diamond shaped. But I'm having problem converting screen coordinates to tile row and column mathemetically. My solution has to be mathemetically... does anyone know the solution? Please help. Thanks in advance.

Share this post


Link to post
Share on other sites
Advertisement
I'm assuming you mean that the rectangle you showed in your post would be rotated 45 degrees clockwise (ie. with [0,0] at the top and [0,1] beneath and to the right of it, etc. - which is reverse of how I have mine).

In which case:

tileX = (screenY / tileHeight) - (screenX / tileWidth);
tileY = (screenY / tileHeight) + (screenX / tileWidth);

Assuming that screen (0,0) corresponds to tile(0,0).

Tilewidth and tileheight are the dimensions of the tile bitmap, if you like.

Share this post


Link to post
Share on other sites
Oh I see. Sorry, I misunderstood - in that case I don't know the answer. I find it easier to use an abstract rectangular tilemap (like a grid of paper, say), and have it staggered only at the rendering stage (like Diablo etc.). If your tilespace is such that 0,0 is in the upper left of the screen and n,n is in the lower right, then I'm not sure how you'd go about converting screen to tile coordinates I'm afraid (although I'm sure it is possible I'm sure).

Maybe someone else has done this?

Share this post


Link to post
Share on other sites
I think here is the answer .... in javascript.

http://opencjk.org/~yumj/isometric_mouse2tile.html

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement