I am using a mouse for my game and when you go to cast a spell the tile under the mouse is lit up to indicate where you will cast the spell, but I am having trouble finding it.
I set x,y variables to the screeen coordinates of an event on the upper left tile(0,0) on the map to get an offset and I then multiply it by -1 to get positive coordinates. I then add the mouse's x,y screen coordinates to the x,y variables. Afterwards I divide by 16 and take the terrain id of the x,y variables. This partially works, but for some reason when the mouse isn't in the center of the tile I get the wrong tile coordinates.
Anyone have any ideas how I could get accurate tile coordinates with mouse screen relative coordinates?
FIXED: I did my math wrong, I wasn't suppose to multiply by -1 and I had to adjust the variables some.