Click the right square on a map drawn as tilted diamonds
On a map drawn from an angle, the square under the mouse is not found by dividing the position by the tile size. People then click one square and select the neighbour, or select something when they click the sky above the map. Here is the conversion that picks the right square, also near the edges.
Why this works
A tilted map is a flat grid squeezed and turned, so finding the square under the mouse means undoing that squeeze and turn in reverse order. Rounding downward, not toward zero, keeps points left of or above the map from being mistaken for the first square.
When not to use it
Wrong for maps drawn from the side or straight from above, where plain division by tile size does the job. It also fails when the ground has hills, since the picture height no longer matches the grid; then pick against what is drawn.
In the full entry
- What to build, step by step
- Starting values and the reason for each
- 3 common mistakes and the fix
- 19 lines of example code with 4 checks that pass
- How your AI shows you that it works
Say this to your AI
Use the Spielerando entry "Click the right square on a map drawn as tilted diamonds" (read_entry isometric-tile-picking) in my game. Build it step by step, and show me how you checked that it works.Or skip this and connect the MCP: your AI then finds all of this by itself.Connect the MCP