Square to Isometric (and back)

by Crazy Star

Posted on September 12, 2011 at 7:51 PM

Very basic example of converting mouse coordinates to isometric coordinates for both drawing and clicking.

Hold the mouse in one grid and a circle will appear in the same cell of the other grid.

The tricks are:

isoX = sqrX-sqrY;
isoY = (sqrY+sqrX)/2;

sqrX = isoX/2+isoY;
sqrY = -isoX/2+isoY;

Or was it the other way around? :)

(The thing at the bottom was just some extra stuff I needed)

LAR Games commented September 14, 2011 at 1:00 AM
How are people submitting things? I cant do it..
Nonsuch Games commented September 14, 2011 at 3:32 AM
Neat example. I was thinking of tinkering with something like this.

@LAR Games: The submit button at the top of the page, though I'm pretty sure it gives everybody problems.
Mega commented September 14, 2011 at 7:31 AM
Nice. Now I'll have to post some projection examples. Raycasting anyone?
Cosine commented September 14, 2011 at 10:10 PM
Doop Not to say that you haven't done well, though. I haven't checked either example (probably never will), but this one looks nice.
Crazy Star commented September 15, 2011 at 12:25 PM
Thanks for the comments :)

If I could edit this then I'd link to that alternative example that you posted. Though I still prefer my own method as it used less obscure calculations to do the same thing and more, as well as convert back from isometric which you'll likely need to do if you want to use the mouse...
Wasn't aware of the other example though. Thanks for poining that out to me :)
Alert Games commented September 15, 2011 at 7:24 PM
I think I should download this in case i ever need it :)