Commit Graph

6 Commits

Author SHA1 Message Date
c5c1436bc7 Fix WebGL2 for web build (raylib 5 requires VAOs)
Add -sUSE_WEBGL2=1 -sMIN_WEBGL_VERSION=2 -sMAX_WEBGL_VERSION=2 to both
EMCC_CFLAGS and linker flags. raylib 5.x enables VAOs by default which
require WebGL2; without it glVertexAttribPointer fails on the clientside
property of an undefined VAO object.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-07 00:39:03 +01:00
951bd51f12 Add WebAssembly build support via Emscripten
- Cargo.toml: gate `wayland` feature behind cfg(not(wasm32)) so the
  dependency resolves correctly for both native and web targets
- .cargo/config.toml: WASM linker flags (ASYNCIFY, GLFW, memory growth)
- build_web.sh: sets required EMCC_CFLAGS, builds, copies artefacts to web/;
  accepts --serve to start a local HTTP server
- web/index.html: minimal Emscripten shell with canvas and status line
- .gitignore: exclude generated web/*.js and web/*.wasm artefacts
- README: document web build prerequisites and usage

ASYNCIFY lets the native while-loop main loop run unchanged in the browser.
Build output: ~267 KB JS + ~458 KB WASM.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-07 00:35:21 +01:00
a320ee537f Add README with gameplay, controls, architecture, and tuning docs
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-07 00:22:25 +01:00
65a5ba99c0 Apply code review improvements across all modules
Bugs fixed:
- Remove duplicate/corrupt draw_text in draw_active_effects_hud (screen_width as u8 = 0)
- Fix pickup-enemy avoidance using actual enemy center-x instead of platform midpoint
- Remove redundant `as f32` cast on an already-f32 expression

DRY / data coupling:
- Effect label and color now stored in each effect struct and passed from PickupDef::create_effect,
  eliminating the three-way duplication between Config, PickupEffectType, and ActiveEffect impls

Config-driven level gen:
- Add enemy_platform_margin and pickup_platform_margin fields to Config
- Replace magic number literals in level_gen with cfg fields

Encapsulation and code clarity:
- score_f made fully private; tests assert on the public score: u64
- Pickup::collected flag removed; collect_pickups uses retain for immediate removal
- Platform::top() and Enemy::top() removed (transparent aliases for .y); call sites use .y directly
- Game-over restart prompt now blinks at ~2 Hz using world.elapsed

Rust idioms:
- #[derive(Debug)] added to Player, Platform, Enemy, Pickup, PickupDef,
  PickupEffectType, Config, GameState, and all three effect structs
- [profile.release] added to Cargo.toml (lto=thin, codegen-units=1, panic=abort)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-07 00:21:44 +01:00
401f91b0fe Add unit tests across all game modules (42 tests)
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-06 23:11:03 +01:00
090f5d4a6d Add 2D endless runner game with pickups and coyote time
- Platformer endless runner: fixed player x, world scrolls left
- Logarithmic speed curve: initial + factor * ln(1 + t / time_scale)
- Enemies stomped from above; side/bottom contact kills player
- Procedural level generation with StdRng seeded from SystemTime
- Object pooling via Vec::retain + frontier-based generator
- Coyote time: grace window after leaving platform edge
- Data-driven pickup system with trait-based effects (ActiveEffect)
  - Invulnerability, JumpBoost, ScoreMultiplier — extend via config
- Score accumulates with per-effect multiplier; stomp bonuses scaled
- Game over screen with score, best score, restart prompt
- HUD: score, speed bar, active effect timer bars

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-06 23:03:09 +01:00