Sealed Arena Geometry

Sealed arenas are square, fixed-size rooms with permanently impenetrable walls. They replace the legacy circular BossRoom (which spawned large and shrank over 30 seconds) for boss encounters: the arena materializes at full size in a 'locked' state, centered on the ship at the moment of spawn, and never moves until torn down.

Footprint

  • Half-extent: SEALED_ARENA_HALF_SIZE = 1400 world units (from data/level-progression.ts).
  • Full footprint: 2800 × 2800 world units. The arena is a square with corners at (cx ± 1400, cy ± 1400) where (cx, cy) is the ship’s position at spawn time.
  • Wall thickness: SEALED_ARENA_WALL_THICKNESS = 2000 world units. This is the cuboid thickness of each wall collider — far larger than any single-frame knockback can plausibly traverse.
  • Anchor: Built around ship.x, ship.y so the player never drops in clipping a wall. In practice the bridge resets the ship to (0, 0) on level-advance, so arenas are typically centered at the origin.

Three enforcement mechanisms

The sealed arena uses three independent layers — each on its own would be insufficient; together they make escape impossible.

  1. Per-frame ship clamp. updateBossRoom (in boss-room.ts) clamps the ship’s position to the room interior every frame. This handles the slow-drift case where a force tries to push the ship through over many frames.
  2. Rapier static cuboid colliders. Four static cuboids are registered via RapierTerrain.addArenaWall, one per side. They block the ship’s physics body, projectiles, and any knockback-pushed entity. Corners overlap by SEALED_ARENA_WALL_THICKNESS so diagonal pushes can’t squeeze through a corner gap.
  3. Wall thickness floor. The visual + collider thickness is rendered at ≥ SEALED_ARENA_WALL_THICKNESS (2000 units) so even single-frame teleports/knockbacks of plausible magnitudes still land inside the wall, not past it.

The four walls are placed with their inside face flush at ±1400 from the center:

  • Top: cuboid at (cx, cy − 1400 − 1000), half-extents (2400, 1000)
  • Bottom: cuboid at (cx, cy + 1400 + 1000), half-extents (2400, 1000)
  • Left: cuboid at (cx − 1400 − 1000, cy), half-extents (1000, 2400)
  • Right: cuboid at (cx + 1400 + 1000, cy), half-extents (1000, 2400)

The side half-length of 2400 = half + wallThickness is what extends each wall past the corners.

When sealed arenas fire

Sealed arenas spawn at the start of any level whose LevelKind is 'mini_boss' or 'boss', per the run sequences in data/level-progression.ts:

  • Normal mode (5 levels): mini-boss at level 3, boss at level 5.
  • Challenge mode (10 levels): mini-bosses at levels 3, 6, 9; boss at level 10.

On entry the engine:

  1. Calls spawnSealedArena(), which strips all biome terrain + floaters whose centroid sits within 1.1 × half of the center (slightly oversized cull so chunks straddling the wall don’t leave halves clipping in).
  2. Snaps the ship’s Rapier body to the arena center and clears any stray enemy bodies from the prior level.
  3. Constructs a BossRoom in 'locked' state with shape: 'rect', targetW = targetH = 2800, currentR = targetR = 1400. Helpers that expect a circular room fall back to min(W, H) / 2.
  4. Sets the global flag game._sealedArenaActive = true so other systems know they’re inside a sealed-arena level.
  5. Wraps the room in a BossArena via the existing createBossArena infrastructure, then calls spawnBoss to populate the encounter.

How they end

A sealed arena persists until the boss is killed. The level-advance flow then calls teardownSealedArena(), which:

  1. Calls RapierTerrain.clearArenaWalls() to drop all four wall colliders.
  2. Sets game._sealedArenaActive = false.

The BossRoom + BossArena objects themselves are cleared by the caller (typically onBossEncounterEnd). Both layers of teardownSealedArena are no-ops if no arena is active, so the call is safe in any state.

The arena does not have an explicit fail-state geometry — death is handled by the usual run-end path, and after results the next level builds a fresh arena (if applicable) at the new ship spawn.

  • gameplay/concepts/boss-room-shrink.md — the legacy circular BossRoom shrink pattern that sealed arenas supersede.
  • gameplay/mini-bosses.md, gameplay/bosses.md — the encounter types that trigger sealed arenas.
  • code/engine/boss/sealed-arena.md — implementation reference for spawnSealedArena / teardownSealedArena.