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 = 1400world units (fromdata/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 = 2000world 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.yso 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.
- Per-frame ship clamp.
updateBossRoom(inboss-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. - 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 bySEALED_ARENA_WALL_THICKNESSso diagonal pushes can’t squeeze through a corner gap. - 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:
- Calls
spawnSealedArena(), which strips all biome terrain + floaters whose centroid sits within1.1 × halfof the center (slightly oversized cull so chunks straddling the wall don’t leave halves clipping in). - Snaps the ship’s Rapier body to the arena center and clears any stray enemy bodies from the prior level.
- Constructs a
BossRoomin'locked'state withshape: 'rect',targetW = targetH = 2800,currentR = targetR = 1400. Helpers that expect a circular room fall back tomin(W, H) / 2. - Sets the global flag
game._sealedArenaActive = trueso other systems know they’re inside a sealed-arena level. - Wraps the room in a
BossArenavia the existingcreateBossArenainfrastructure, then callsspawnBossto populate the encounter.
How they end
A sealed arena persists until the boss is killed. The level-advance flow then calls teardownSealedArena(), which:
- Calls
RapierTerrain.clearArenaWalls()to drop all four wall colliders. - 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.
Related
gameplay/concepts/boss-room-shrink.md— the legacy circularBossRoomshrink 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 forspawnSealedArena/teardownSealedArena.