I seem to be having a bit of trouble detecting the tile below my mouse cursor.
I have a 2d map that is 32x64 tiles in size, each tile is 32x32 pixels big. I move through the map using the arrow keys that += and -= xScroll & yScroll variables by a given speed.
I’m able to get the tile below the mouse by dividing the mouse x & y by 32. This all works fine until I start moving. The wrong tiles get selected when the xScroll & yScroll change. I’ve tried adding the xScroll & yScroll to the mouse x & y but that has no effect.
Here’s some source code. http://pastebin.com/XTqV2FdL