Iso Engine Mouse Coordinates -[RESOLVED]-
Hi there,
by now, I've finished the graphical display of my Iso Engine.
I'm saving the Tiles in a 2dimensional Matrix, so my GameField looks like this...
GameTile GTMAP[10][10] =
{
1,1,1,4,1,1,1,1,1,1,
1,1,1,1,1,1,1,1,1,1,
1,1,1,1,1,1,1,1,1,1,
1,1,2,3,4,1,1,1,1,1,
1,1,1,2,3,1,1,1,1,1,
1,1,2,1,6,1,1,1,1,1,
1,1,1,1,1,1,1,1,1,1,
1,1,1,1,1,1,1,1,1,1,
1,1,1,1,1,1,1,1,1,1,
1,1,1,1,1,1,1,1,1,1,
}
Where every number stands for a different type of terrain (not hardcoded, of course).
Now, my question is: Given a paoint X(x/y) on the map (a mouse coordinate, to be precise), how can I check which tile I am in?
Since it's not standard rectacular, a normal division by height and width won't work, so my attempt was to first do the normal division to know where about i am, seperate the most likely tile into four triangles, use the formula y=kx+d for linear functions and get the max for my y coordinate this way...
Unfortunately, that's too slow...
Any ideas on how to do it?