2
\$\begingroup\$

I know this has been discussed here before, but I couldn't find an easy solution for my particular problem. I have a tile system and I'd like to convert screen coordinates into isometric tile coordinates. Here's an image to explain what I need:

isometric coordinates conversion

As you can see, the coordinates are between 0 and 1. I can't figure out a formula for the conversion though. Can you guys help me?

\$\endgroup\$

1 Answer 1

3
\$\begingroup\$

These are (simplified version of) the formulas I use in my current project wizardwar.com:

 tile_x = screen_y - 0.5 + screen_x;
 tile_y = (screen_y - 0.5 - screen_x) * -1;

By the way: I would recommend you to use different terminology for screen-coordinates and world-coordinates to avoid mixups. I use x and y for screen coordinates and left-down and right-down for tile coordinates. This saved me from more than one brain-knot. In your example, tile_y would be be left-up and tile_x would be right-up.

\$\endgroup\$
1
  • \$\begingroup\$ Just call them sceenX or gameX if in a method where this is not clear. l and r is a bit open for interpretation because it's uncommon. \$\endgroup\$ Sep 2, 2014 at 18:55

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .