Spielerando

On a diamond-shaped map the camera can drift into the empty corners

Keeping the camera inside a rectangle works for a flat map, but a slanted-view map is shaped like a diamond, and a rectangle leaves large empty triangles where the view floats over nothing. Here is a way to keep the camera on the map that also lets it slide along the border instead of sticking.

Why this works

A diamond on the screen is a plain square on the ground. Limiting the view where the map is square is simple, and turning it back gives the diamond for free, with the bonus that pushing against an edge slides along it instead of sticking.

When not to use it

Do not bother when the map has an irregular outline, such as islands or rooms of odd shape. A square test then lets the view into empty water. Check the view against the real outline, or hide the empty space with a border picture.

In the full entry

  • What to build, step by step
  • Starting values and the reason for each
  • 3 common mistakes and the fix
  • 28 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 "On a diamond-shaped map the camera can drift into the empty corners" (read_entry strategy-clamp-camera-inside-diamond-map) 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