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

Author
Message
NewDarken
16
Years of Service
User Offline
Joined: 12th Jan 2006
Location: Nevada
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

Van B
Moderator
20
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
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.
NewDarken
16
Years of Service
User Offline
Joined: 12th Jan 2006
Location: Nevada
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
http://www.kirupa.com/forum/showthread.php?376083-Picking-Tile-in-staggered-isometric-map
Maybe try something like this...



BMacZero
16
Years of Service
User Offline
Joined: 30th Dec 2005
Location: E:/ NA / USA
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

Attachments

Login to view attachments

Login to post a reply

Server time is: 2022-12-08 16:38:24
Your offset time is: 2022-12-08 16:38:24