Spielerando

Drawing a selection box near the edge scrolls the map but the box goes wrong

When you drag a box over many units and the map scrolls along, the box often selects the wrong area, because it was remembered in the wrong kind of position. Here is what to store at the start of the drag, how the box is rebuilt on every frame, and how to tell a click from a drag.

Why this works

A box should stay fastened to the ground the player started on, not to the glass of the screen. Remembering the corner as a place on the map, and the pointer as a place on the screen, lets the box grow over whatever scrolled past.

When not to use it

It is the wrong tool for choosing a single thing, or on a touch screen where fingers are too coarse for a box. Offer a tap, a double tap to pick all of one kind, or a button for the whole group.

In the full entry

  • What to build, step by step
  • Starting values and the reason for each
  • 3 common mistakes and the fix
  • 40 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 "Drawing a selection box near the edge scrolls the map but the box goes wrong" (read_entry strategy-selection-box-while-camera-scrolls) 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