I have a tile based game and I need to find the closest tile within a 32px
radius. So say a user is at 400, 200
and the user clicks at 500, 400
. I need to create a path or line from the player to the mouse position on click and the closest tile that is underneath the path within 32px
(or 2 tiles) must be chosen. The map is tiled at 16px
.
A function call to see if a tile is at a given tile position is available Map.at(x,y)
.
I just don't know the maths to use to work this out.
The block blocks are within 16px, the red are within 32px. The grey block is the tile to be destroyed and the blue line is the invisible path between the player and mouse.