# Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

### 2D All the way! / Picking tile on a staggered isometric map

Message
Posted: 17th Dec 2012 05:07
Hello!
I have been looking and trying for quite a while now, but can't seem to work out an algorithm for figuring out which tile is selected on a staggered isometric map using 64x32 tiles with a diamond shape inside.

Here is a pic of my map...

The first row is drawn, then the x is offset to the right by 32 and the next row is drawn.

Anyone have any good math skills to throw some algorithms my way for this?
Thanks for any help!

PS: My math isn't exactly top notch, so please keep that in mind. Smiley

Posted: 18th Dec 2012 16:54
I'm sure I have a solution for this somewhere, but it's best to wait and see if someone has an efficient formula. I think I used the centre point of each diamond, worked out the distances to the clicked location to work out which side of the 'line' the user selected. Anyway, will post back if nobody comes up with a solution.

I got a fever, and the only prescription, is more memes.
Posted: 19th Dec 2012 05:56
I appreciate the help. It being the work week, I didn't get a chance to really put some time into any solution and I definitely am not going to post the embarassing hack I was attempting.

I did get a plug and play solution involving some math equations that are quite a bit beyond me that I will post for anyone running into the same situation. It works great!

dawsonk
Maybe try something like this...

Posted: 20th Dec 2012 04:13 Edited at: 20th Dec 2012 04:14
I had to solve this for a project not too long ago - in Flash, too. I managed to find a pretty elegant method:

This gets you the grid position of the tile at the screen position realpos. One caveat is that it rotates the axes, so you have the X-axis increasing diagonally from top-left to bottom-right, and the Y-axis decreasing away from that toward the top-right and increasing toward the bottom-right, as I have crudely illustrated here:

http://brianmacintosh.com
"'Who's that primitive entity accessing sliding collision data from my bridge?!', the troll roared." - TheComet