# Minimap a corner overview of a scrolling 2D world ```{raw} html ▶ Run in browser ``` **Tags:** `ui` `minimap` `camera` `2d` `hud` A player roams a world several screens wide while a Camera2D follows, and a minimap panel in the top-right corner shows the whole world at once: a world-to-panel affine maps landmarks and patrolling enemies to dots, the player to a brighter marker, and the camera's current viewport to an outlined rectangle. Drawing the map with screen-space Draw2D from the same world data is the standard approach in 2D: a render-to-texture second view of the main world is not available, and a SubViewport renders only its own subtree. ## What it demonstrates - A world -> minimap affine (`world_to_map`): one uniform scale plus the panel's top-left offset maps any world position onto the panel. - Screen-space overlay drawing: `screen_space=True` on Draw2D calls bypasses the active Camera2D, so the panel stays pinned while the world scrolls. - `push_clip` / `pop_clip` so map content never spills outside the panel. - The camera's viewport as a map rectangle, from `camera.current`, `zoom`, and the live window size. - `Camera2D` follow with smoothing and `limit_*` clamped to the world edges. Controls: WASD / arrows - Move the player (camera follows) M - Toggle the minimap ESC - Quit Run: uv run python examples/features/ui/minimap.py Headless self-check: uv run python examples/features/ui/minimap.py --test ## Source ```{literalinclude} ../../examples/features/ui/minimap.py :language: python :linenos: ```