Add pause menu, laser turret, charger/spawner enemies, and Mars campaign

Implement four feature phases:

Phase 1 - Pause menu: extract bitmap font into shared engine/font
module, add MODE_PAUSED with Resume/Restart/Quit overlay.

Phase 2 - Laser turret hazard: ENT_LASER_TURRET with charge/fire/
cooldown state machine, per-pixel beam raycast, two variants (fixed
and tracking). Registered in entity registry with editor icons.

Phase 3 - Charger and Spawner enemies: charger ground patrol with
detect/telegraph/charge/stun cycle (2s charge timeout), spawner that
periodically creates grunts up to a global cap of 3.

Phase 4 - Mars campaign: two handcrafted levels (mars01 surface,
mars02 base), mars_tileset.png, PARALLAX_STYLE_MARS with salmon sky
and red mesas, THEME_MARS_SURFACE/THEME_MARS_BASE for the procedural
generator with per-theme gravity/tileset/parallax. Moon campaign now
chains moon03 -> mars01 -> mars02 -> victory.

Also fix review findings: deterministic seed on generated level
restart, NULL checks on calloc in spawn functions, charge timeout
to prevent infinite charge on flat terrain, and stop suppressing
stderr in Makefile web-serve target so real errors are visible.
This commit is contained in:
Thomas
2026-03-02 19:34:12 +00:00
parent e5e91247fe
commit d0853fb38d
22 changed files with 1519 additions and 147 deletions

38
TODO.md
View File

@@ -67,3 +67,41 @@ blue-white flare, 18 particles mixed into regular burst) and
`particle_emit_jetpack_boost_trail()` (blue sparks + pale blue wisps,
3 particles/frame). Both activate only when `jetpack_boost_timer > 0`.
Burst fires on dash start, trail emits each frame during dash.
## ~~Pause menu~~ ✓
Implemented: extracted bitmap font from `editor.c` into shared `engine/font`
module (`font.h`/`font.c`). Added `MODE_PAUSED` game state to `main.c` with
semi-transparent overlay, menu items (Resume / Restart / Quit), up/down
navigation, confirm with jump/enter. Restart reloads file-based levels or
regenerates procedural levels.
## ~~Laser turret hazard~~ ✓
Implemented: `ENT_LASER_TURRET` entity with state machine (IDLE → CHARGING →
FIRING → COOLDOWN). Beam uses per-pixel raycast via `tilemap_is_solid()`.
Player damage via point-to-line distance check. Rendering with
`SDL_RenderDrawLine` and perpendicular offset for beam thickness.
Two variants: `laser_turret` (fixed, aims left) and `laser_turret_track`
(rotates toward player at 1.5 rad/s during idle/charge, locks on fire).
Both registered in entity registry with editor icons.
## ~~New enemies: Charger and Spawner~~ ✓
Implemented in `enemy.h`/`enemy.c`:
- **Charger** — Ground patrol → ALERT (0.5 s telegraph) → CHARGE (150 px/s
rush) → STUNNED (0.8 s on wall hit, reverses). 2 HP. Detects player in
horizontal line-of-sight within 200 px.
- **Spawner** — Stationary. Spawns grunts every 4.5 s (max 3 alive via
`count_alive_grunts()`). Pulses before spawn. 3 HP, destructible. Purple
color scheme. Both registered in entity registry with editor icons.
## ~~Mars campaign~~ ✓
Implemented: two handcrafted levels plus procedural generator support.
- **mars01.lvl** (250×23, Mars Surface): low gravity (370), wind, wide-open
red terrain, charger + grunt enemies, spacecraft intro. New
`mars_tileset.png` and `PARALLAX_STYLE_MARS` (salmon sky, red mesas, dust).
- **mars02.lvl** (40×46, Mars Base): normal gravity (700), tall vertical
corridors with narrow passages, turrets, laser turrets (fixed + tracking),
spawners, chargers, grunts. Victory exit at bottom.
- Generator: `THEME_MARS_SURFACE` / `THEME_MARS_BASE` with per-theme gravity,
bg color, parallax style, tileset path, segment probabilities, and height
zone assignment. Mars themes added to procedural progression (6 options).
- Moon campaign now chains to Mars: moon03 → mars01 → mars02 → victory.