Add new level transition state machine

This commit is contained in:
2026-03-14 16:29:10 +00:00
parent 6d64c6426f
commit 7605f0ca8c
15 changed files with 615 additions and 55 deletions

30
TODO.md
View File

@@ -160,11 +160,25 @@ The spacecraft fly-in animation should only play on surface levels (moon01,
mars01, etc.). Interior/base levels (mars02, mars03, generated mars_base,
generated station) should skip it — the player is already indoors.
## New level transition styles: elevator and teleporter
Two new transition animations to complement the spacecraft fly-in:
- **Elevator** — Doors slide shut, brief pause (screen shake / rumble),
doors slide open onto the new level. Good for base/station interior
transitions (mars02 → mars_base, between generated station levels).
- **Teleporter** — Energy charge-up effect around the player, flash/warp
distortion, player materialises in the new level. Good for cross-planet
jumps or generated-to-handcrafted transitions.
## ~~New level transition styles: elevator and teleporter~~ ✓
Implemented: `src/game/transition.h` / `transition.c` module with two-phase
transition state machine (outro on old level → level swap → intro on new level).
- **Elevator** — Two horizontal doors slide inward from top/bottom (0.6 s),
hold closed with screen-shake rumble (0.3 s), then slide apart on the new
level (0.6 s). Smooth ease-in-out motion, dark gray industrial color,
bright seam at the meeting edge. Used for base/station interior transitions.
- **Teleporter** — Scanline dissolve: 3 px-tall horizontal bands sweep
across the screen in alternating directions with staggered top-to-bottom
timing (0.5 s), then white flash (0.15 s). Intro reverses the sweep
bottom-to-top (0.5 s). Uses `teleport.wav` sound effect.
New `MODE_TRANSITION` game state in `main.c` pauses gameplay during the
animation. Level-load dispatch extracted into `dispatch_level_load()` helper,
called both from instant transitions and from the transition state machine.
New `.lvl` directives `TRANSITION_IN` and `TRANSITION_OUT` with values
`none`, `spacecraft`, `elevator`, `teleporter`. Parsed in `tilemap.c`,
saved by editor and level generator dump. All three procedural generators
(generic, station, mars_base) set `TRANS_ELEVATOR` for interior themes.
Handcrafted levels updated: mars02, mars03, level01, level02.