Get mouse coordinates on a rotated "grid"
Posted: Thu Mar 14, 2019 4:23 am
So I'm working on this thing...
(Everyone's doing it these days)
And I got to thinking, it would be neat if I could figure out what tile the mouse is actually over. But I don't know the math to do that.
The "ground" image (The checkerboard grid image) is a simple Löve transformation where it's rotated at the angle I want first, then scaled to give it a fake perspective. Here's another simpler example with the Y scaling and fake perspective scaling turned off:
So how would I go about figuring out where the mouse is given that the corner shown above is 0,0 and the image's x and y offset is the position of the player? (The purple square) Surely it's pretty simple. But Google isn't helping and only seems to have answers for dealing with plain old isometric grids. My grid has free-rotation.
Edit: How in the world did I end up putting this in Games and Creations? Sorry I meant to put it in Support.
(Everyone's doing it these days)
And I got to thinking, it would be neat if I could figure out what tile the mouse is actually over. But I don't know the math to do that.
The "ground" image (The checkerboard grid image) is a simple Löve transformation where it's rotated at the angle I want first, then scaled to give it a fake perspective. Here's another simpler example with the Y scaling and fake perspective scaling turned off:
So how would I go about figuring out where the mouse is given that the corner shown above is 0,0 and the image's x and y offset is the position of the player? (The purple square) Surely it's pretty simple. But Google isn't helping and only seems to have answers for dealing with plain old isometric grids. My grid has free-rotation.
Edit: How in the world did I end up putting this in Games and Creations? Sorry I meant to put it in Support.