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\$
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\$
  • \$\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\$ – Benedikt S. Vogler Sep 2 '14 at 18:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.