Commit Graph

28 Commits

Author SHA1 Message Date
Thomas
d0853fb38d 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.
2026-03-02 19:34:12 +00:00
Thomas
e5e91247fe Add proper Containerfile and update Makefile to include the web shell 2026-03-02 17:35:36 +00:00
Thomas
1961cd353b Fix on_ground flickering on one-way platform tiles
The platform collision check in resolve_tilemap_y required vel.y > 0
(strictly falling), so once landing zeroed vel.y the check would fail
next frame. Gravity would add a tiny downward velocity, the platform
would catch it again, and the cycle repeated — causing animation
jitter and repeated landing dust particles.

Change the condition to vel.y >= 0 so platforms resolve when resting.
Extend the ground-stick anti-flicker probe to also detect TILE_PLATFORM
tiles (was TILE_SOLID only), with a proximity guard to preserve
jump-through-from-below behavior.
2026-03-01 18:33:45 +00:00
Thomas
302bcc592d Rebind Space to jump, gate editor behind localStorage flag
Space is now the alternate jump key (was shoot). Web shell shows
game controls by default and hides editor UI unless
localStorage.show_editor is set to 'true'. The E key and ?edit URL
are blocked when the editor is not enabled.

Also fix Makefile to track web/shell.html as a WASM link dependency
so shell changes trigger a rebuild.
2026-03-01 18:24:21 +00:00
Thomas
3584aace75 Adjust spacecraft thruster particle origin up and right by 8px 2026-03-01 18:12:23 +00:00
Thomas
bb0b9ddce1 Add jetpack fuel pickup and slow base recharge to 30s
Jetpack charges now take 30s to passively recharge (up from 3s),
making fuel management a core gameplay loop. A new fuel canister
powerup (POWERUP_FUEL) restores exactly one charge on pickup.

The existing jetpack powerup remains as the rare full-refill + 15s
boost. Fuel pickups replace most procedural jetpack spawns at higher
spawn rates to compensate for the weaker per-pickup value. Fuel
canisters also appear in corridors and arenas.

Adds orange canister pixel art, editor icon, entity registry entry,
and places fuel pickups throughout moon01.
2026-03-01 18:06:32 +00:00
Thomas
fdba6ef077 Add Earth sprite to moon parallax background
Render earth.png as a non-tiling feature sprite in the moon sky,
drawn between the far starfield and near crater terrain layers.

Introduce ParallaxFeature struct for single-instance background
sprites that scroll with the camera but never tile. Clean up the
feature reference in parallax_free to prevent stale pointers
between level transitions.
2026-03-01 17:49:14 +00:00
Thomas
6c4b076c68 Add per-level wind atmosphere property
WIND directive in .lvl files sets a constant horizontal force (px/s^2)
that pushes entities, projectiles, and particles. Positive is rightward.

Wind is applied as acceleration in physics_update() (halved on ground),
directly to projectile and particle velocities, and as a gentle position
drift on flyers. Entities with gravity_scale=0 (drones, spacecraft) are
unaffected. Levels default to no wind when the directive is absent.
2026-03-01 17:13:01 +00:00
Thomas
cdba479ced Fix TileDef rendering at (0,0) and open editor with current level
Remove the (tex_x || tex_y) guard in tilemap_render_layer() that
silently ignored TileDefs pointing to tileset position (0,0). The
tile_def_count check alone is sufficient to distinguish defined from
undefined tiles.

Sync the editor palette to use TileDef tex coords when available,
fixing the mismatch where the palette showed tiles by sequential grid
position while the canvas used TileDef coordinates.

Save all TileDef entries unconditionally to prevent round-trip data
loss for tiles at position (0,0) with no flags.

Track the active level file path so pressing E during gameplay opens
the editor with that level loaded instead of a blank canvas.
2026-03-01 17:01:54 +00:00
Thomas
372ea3d586 Upgrade level editor for moon campaign support
Preserve tileset path and parallax style on save instead of
hardcoding tileset.png. Add tileset cycling (T key), tile flag
editing (F key for solid/platform/hazard/none), and 8x8 pixel
mini-icons for all entity types in the palette and canvas.

Fix entity palette not appearing when editor starts without a
prior level load by splitting entity_registry_init into populate
and init phases. Fix bitmap font rendering dropping the top row
by correcting FONT_H from 6 to 7. Widen toolbar button spacing.

Fix invisible collision from placed tiles lacking TileDefs by
calling ensure_tile_def on pencil and fill placement. Fix editor
hotkeys not working in the web build by latching key presses from
SDL_KEYDOWN events instead of comparing keyboard state snapshots.
2026-03-01 16:48:53 +00:00
Thomas
df3bc29fb7 Support large maps up to 8192x8192 tiles
Raise hard map size cap from 4096 to 8192 via MAX_MAP_SIZE constant.
Replace fixed 16 KB fgets buffer with dynamic line reader that handles
arbitrarily long tile rows. Check calloc returns for tile layer
allocation.

Add entity distance culling: skip updates for entities beyond 2x screen
width from camera, skip rendering beyond 64 px margin. Dead entities
bypass culling so cleanup callbacks always run. Player, spacecraft,
drone, and moving platforms set ENTITY_ALWAYS_UPDATE to opt out.

Replace naive 4-neighbor flood fill with scanline algorithm (O(height)
stack instead of O(area)) for safe use on large maps.

Raise MAX_ENTITY_SPAWNS from 128 to 512 and MAX_EXIT_ZONES from 8 to
16 to support populated large levels.
2026-03-01 15:17:58 +00:00
Thomas
ad2d68a8b4 Add height zones, jetpack boost particles, and TigerStyle guidelines
Level generator: add vertical variety with tall levels (46 tiles).
Segment generators accept ground_row parameter, SEG_CLIMB connects
height zones, transitions inherit predecessor ground row to prevent
walkability gaps. Climb segments respect traversal direction.

Jetpack boost: add blue flame particles during dash (burst + trail)
and continuous idle glow from player back while boost timer is active.

Camera: add 30px vertical look-ahead when player velocity exceeds
50 px/s.

Fix flame vent pedestal in gen_pit to use ground-relative position
instead of map bottom (broken in tall HIGH-zone levels).

Add TigerStyle coding guidelines to AGENTS.md adapted for C11.
Add tall_test.lvl (40x46) for height zone validation.
2026-03-01 14:57:53 +00:00
Thomas
9d828c47b1 Add moon campaign: 3 levels with spacecraft transitions 2026-03-01 14:27:15 +00:00
Thomas
66a97a4beb Change exit ship trigger from proximity distance to exit zone overlap 2026-03-01 12:45:07 +00:00
Thomas
ded662b42a Add spacecraft exit sequence at level exit zones
Spawn an exit ship when the player approaches an exit zone. The ship
flies in, lands near the exit, and waits for the player to board.
On boarding the player is deactivated, the ship takes off, and the
level transition fires after departure.
2026-03-01 12:38:41 +00:00
Thomas
98d2e87bb3 Add TODO: moon campaign with 3 levels and spacecraft transitions 2026-03-01 12:22:14 +00:00
Thomas
628fa52c52 Extend moon level to 1000 tiles with wide platform gaps
Expand moon01.lvl from 200 to 1000 tiles using a Python generator
script. The level features 27 gap sections with floating one-way
platforms at varying heights, progressing from easy (8-tile gaps) to
challenging (22-tile gaps with tiny platforms). 20 asteroids spread
across the level. Increase tilemap line buffer from 1024 to 16384
bytes to support wide levels.
2026-03-01 12:17:13 +00:00
Thomas
8f538274e7 Use dedicated asteroid collision sound effect 2026-03-01 12:11:16 +00:00
Thomas
fc33658f75 Redesign asteroids: cold moonrock art, bigger impact explosions
Replace warm brown asteroid sprites with cold grey cratered moonrock
using irregular silhouettes and crater detail. No burning/fire trail
since there is no atmosphere on the moon — trail is now grey dust
debris. Ground impact uses a 4-layer explosion: rock shrapnel, dust
plume, ground-level dust spread, and a brief white flash. Player-hit
also gets shrapnel + dust cloud instead of the old small puff.
2026-03-01 12:01:38 +00:00
Thomas
df325ca160 Refine asteroid sprite art 2026-03-01 11:11:52 +00:00
Thomas
94dbe83cfe Refine asteroids: faster, sparser, with horizontal drift
Increase base fall speed (120→200), acceleration (200→350), and respawn
delay (3→6s). Add random horizontal drift (±60 px/s) so asteroids fall
at angles. Widen initial stagger (0-3→0-8s). Reduce moon level from 24
asteroids to 8, spread evenly across the level.
2026-03-01 11:04:00 +00:00
Thomas
49ed2d6f7b Add spatial audio, spacecraft entity, and level intro sequence
Distance-based sound effects with stereo panning for explosions, impacts,
and pickups. Spacecraft entity with full state machine (fly-in, land, take
off, fly-out), engine/synth sound loops, thruster particles, and PNG
spritesheet. Moon level intro defers player spawn until ship lands.

Also untrack build/ objects that were committed by mistake.
2026-03-01 11:00:51 +00:00
Thomas
dbb507bfd2 Add important files reminder to AGENTS.md 2026-03-01 09:51:17 +00:00
Thomas
9af9f65aaf Add TODO with roadmap for audio, large maps, spacecraft art, and asteroid polish 2026-03-01 09:50:22 +00:00
Thomas
3ce879fe98 Fix asteroid double-impact and levelgen theme fallback
Explode asteroid on player contact instead of letting it continue
falling to the ground for a second impact. Return a safe default
theme when theme_count is zero to avoid reading uninitialized data.
2026-03-01 09:41:45 +00:00
Thomas
fac7085056 Add moon surface intro level with asteroid hazards and unarmed mechanics
Introduce moon01.lvl as the starting level — a pure jump-and-run intro
with no gun and no enemies, just platforming over gaps and dodging falling
asteroids. The player picks up their gun upon transitioning to level01.

New features:
- Moon tileset and PARALLAX_STYLE_MOON with crater terrain backgrounds
- Asteroid entity (ENT_ASTEROID): falls from sky, damages on contact,
  explodes on ground with particles, respawns after delay
- PLAYER_UNARMED directive disables gun for the level
- Pit rescue mechanic: falling costs 1 HP and auto-dashes upward
- Gun powerup entity type for future armed-pickup levels
- Segment-based procedural level generator with themed rooms
- Extended editor with entity palette and improved tile cycling
- Web shell improvements for Emscripten builds
2026-03-01 09:20:49 +00:00
Thomas
ea6e16358f Add in-game level editor with auto-discovered tile/entity palettes
Implements a full level editor that runs inside the game engine as an
alternative mode, accessible via --edit flag or E key during gameplay.
The editor auto-discovers available tiles from the tileset texture and
entities from a new central registry, so adding new game content
automatically appears in the editor without any editor-specific changes.

Editor features: tile painting (pencil/eraser/flood fill) across 3
layers, entity placement with drag-to-move, player spawn point tool,
camera pan/zoom, grid overlay, .lvl save/load, map resize, and test
play (P to play, ESC to return to editor).

Supporting changes:
- Entity registry centralizes spawn functions (replaces strcmp chain)
- Mouse input + raw keyboard access added to input system
- Camera zoom support for editor overview
- Zoom-aware rendering in tilemap, renderer, and sprite systems
- Powerup and drone sprites/animations wired up (were defined but unused)
- Bitmap font renderer for editor UI (4x6 pixel glyphs, no dependencies)
2026-02-28 20:24:43 +00:00
Thomas
c66c12ae68 Initial commit 2026-02-28 18:03:47 +00:00