Jump to content

  • Log In with Google      Sign In   
  • Create Account

pizzafan

Member Since 11 Dec 2000
Offline Last Active Yesterday, 10:07 AM

#5059808 I'm desperate. Isometric Mouse Coordinates

Posted by pizzafan on 06 May 2013 - 01:53 PM

well, i also found another link explaining it (http://gamedev.stackexchange.com/questions/34787/how-to-convert-mouse-coordinates-to-isometric-indexes), but as far as i can remember, i used a formula looking like this :

 

tiles(i,j) -> screen(X,Y)

X = i * (w/2) - j * (w/2) + center

Y = i * (h/2) + j * (h/2)

 

screen(X,Y) -> tiles(i,j)

 

i = (X * (h/2) + Y * (w/2) - (center + w/2) * (h/2)) / (w*h/2)

j = (-X * (h/2) + Y * (w/2) + (center + w/2) * (h/2)) / (w*h/2)

 

where center is the offset along the X axis (typically screen width divided by 2, minus half the tile's width).

 

(edit : i just basically tested it, and it works happy.png )




PARTNERS