1
\$\begingroup\$

I'm building an isometric engine.

I use TILE_SIZE * TILE_SIZE (minecraft like) tiles. (I'm using 64 * 64 tiles but I can change the number when I want)

I can access for each tiles to this informations :

 - OFFSET_LEFT(same for every tile on a layer)
 - OFFSET_TOP(same for every tile on a layer)

 - x (classic 2D tiled coordinates)
 - y(//)

 - isometric i

 - isometric j

Tile are drawed at (i * TILE_SIZE, j * TILE_SIZE) I use the following formula to get from x to i and y to j :

int i = (x - y) / 2,
    j = (x + y) / 4;

No problem for displaying, I got my diamond shape :

enter image description here

I try to find a formula to convert my cursor coordinates into those isometrics ones(i, j) with the following questions in mind I wrote on the screenshot.

After doing i * TILE_SIZE, etc... Finding a way to handle offsets(??????)...

I'm gonna render this off-screen :

enter image description here

And banzai, tile detection with some getPixel()...

But to do that, I have to resolve the problems I highlighted with the balise <strong></strong> in the following topic.

Final purpose : get the tile index in my tile array(wich I suppose I can have with i + j ?)

I'm without a clue for days, reading a lot of topic, but some of them sprout some chinese like sqrt(what the... is this creature ?) or matrix transform ????

So even with all the topic on the subject here, I was unable to find a proper solution fulfilling my project's need. Thanks for reading me; ask me if I missed some informations.

EDIT : About the link you gave :

int i = y / tile_size + x / (2 * tile_size),
j = y / tile_size - x / (4 * tile_size);

This one give some 'good results'(I don't really know if it's working but the numbers seem rights) but I can't handle :

- offsets
- when I click outside the map
\$\endgroup\$
2
  • \$\begingroup\$ sqrt is a sqare root. Matrix transformations are a way to use matrices (2D arrays of numbers) for transforming vectors (coordinates) from one frame (your screen) to another (your world). You should definitely read up on them, as they are a very powerful tool once you've got the basics. \$\endgroup\$
    – Quentin
    Commented Jul 6, 2016 at 8:28
  • \$\begingroup\$ To be able to edit your own posts and comment on your own posts and answers to your questions, you should visit this page to have your accounts merged. \$\endgroup\$
    – Vaillancourt
    Commented Jul 6, 2016 at 13:37

0

Browse other questions tagged .