Spielerando

The building preview sits half a tile off the cursor for some sizes

When you place a building, the see-through preview should sit exactly where the mouse is, whatever its size. Small and large, odd and even footprints all look right in different ways, and the easy rounding is right for only some of them. Here is one formula that fits all, with the map border.

Why this works

The eye judges a preview by its centre. A building with an odd width is centred on a tile, one with an even width on a corner between tiles, so one rule that rounds the left edge, not the mouse, puts the middle under the pointer for every size.

When not to use it

Skip it when buildings should snap to a fixed anchor, such as their top-left corner, or when placement is free and not on a grid at all. Then the cursor should simply pick the cell, or the position should follow the mouse smoothly.

In the full entry

  • What to build, step by step
  • Starting values and the reason for each
  • 3 common mistakes and the fix
  • 35 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 "The building preview sits half a tile off the cursor for some sizes" (read_entry strategy-building-ghost-snaps-to-cursor) 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