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

48
src/game/laser_turret.h Normal file
View File

@@ -0,0 +1,48 @@
#ifndef JNR_LASER_TURRET_H
#define JNR_LASER_TURRET_H
#include "engine/entity.h"
#include "engine/camera.h"
#include "engine/tilemap.h"
/* ═══════════════════════════════════════════════════
* LASER TURRET — Hazard that charges up a visible
* indicator beam, then fires a sustained laser for
* several seconds. Two variants:
* - Fixed direction (placed facing left/right)
* - Tracking (slowly rotates toward the player
* during idle/charge, locks on fire)
* ═══════════════════════════════════════════════════ */
#define LASER_WIDTH 14
#define LASER_HEIGHT 14
#define LASER_CHARGE_TIME 1.5f /* seconds to charge up */
#define LASER_FIRE_TIME 2.5f /* seconds beam stays active */
#define LASER_COOLDOWN_TIME 2.0f /* seconds before next cycle */
#define LASER_TRACK_SPEED 1.5f /* radians/s tracking rate */
#define LASER_DAMAGE 1
#define LASER_DAMAGE_CD 0.5f /* seconds between damage ticks */
#define LASER_HEALTH 3
typedef enum LaserState {
LASER_IDLE,
LASER_CHARGING,
LASER_FIRING,
LASER_COOLDOWN,
} LaserState;
typedef struct LaserTurretData {
LaserState state;
float timer; /* countdown for current state */
float aim_angle; /* current aim angle (radians) */
float damage_cd; /* cooldown between damage ticks */
bool tracking; /* true = slowly follows player */
float beam_end_x; /* computed beam endpoint (world) */
float beam_end_y;
} LaserTurretData;
void laser_turret_register(EntityManager *em);
Entity *laser_turret_spawn(EntityManager *em, Vec2 pos);
Entity *laser_turret_spawn_tracking(EntityManager *em, Vec2 pos);
#endif /* JNR_LASER_TURRET_H */