0

I am making a simple(ish) java game in an isometric perspective using lwjgl and I cant figure out how to get the mouse position in the isometric view. Thanks in advance.

Note: the squares are 64x64, window is 640x480, done using a 2d array, and the grid marked "1" in the image below is supposed to be "0".

McGrady
  • 10,869
  • 13
  • 47
  • 69
Kevin K
  • 75
  • 2
  • 6
  • I hope this [link](https://www.gamedev.net/topic/623749-get-the-mouse-position-on-isometric-grid/) will help you – Fady Saad Apr 09 '17 at 02:32
  • see [Improving performance of click detection on a staggered column isometric grid](https://stackoverflow.com/a/35917976/2521214) – Spektre May 16 '18 at 09:18

1 Answers1

0

You can try something like this.

mouse_grid_x = floor((mouse_y / tile_height) + (mouse_x / tile_width));
mouse_grid_y = floor((-mouse_x / tile_width) + (mouse_y / tile_height));

Where mouse_x and mouse_y are your mouse screen coordinates. You will need to render one line at a time. This is just the basic start for any isometric map game you build.

Tip: Use a good matrix calculator tool like wims to do the plot matrix calculation.

Tirtha
  • 11
  • 3