Prompt
# Game Specification: “Tower Climber” (Icy Tower‑like) — **Pure HTML5/JS, Serverless** > Goal: a faithful Icy‑Tower‑style vertical platformer for the web, implemented **entirely client‑side**. No servers, no databases, no third‑party backends. All persistence uses the browser (LocalStorage/IndexedDB). Features that normally need a backend are **redesigned** for a zero‑infrastructure setup. --- ## 0) Feature checklist (what ships) * ✅ Infinite tower, fixed‑step physics, combos, score, increasing auto‑scroll. * ✅ Keyboard controls (← →, Space). Identical feel across platforms via fixed‑timestep and fixed‑point math. * ✅ Pixel‑art vibe with your own assets (no original IP). * ✅ Sound effects and music loops (client‑side only). * ✅ **Leaderboards (local)**: per‑device high scores, per‑day/weekly views, **export/import** JSON to share. * ✅ **Replays (deterministic)**: record inputs + PRNG seed; export as file or share via URL hash (no server). * ✅ **Ghost runs**: race against your own best replay or an imported replay file. * ✅ **Achievements (local)**: \~20 unlocks stored locally; export/import with the same mechanism. * ✅ **Skins/characters**: client‑side sprite sheets + JSON manifests; unlock rules stored locally. * ✅ Optional PWA: offline install, caching of assets via service worker. > Out of scope by design: true global online leaderboards or cloud sync. These require a backend; we replace them with import/export and shareable replays. --- ## 1) Core loop (GDD) * Start at floor 0; climb by landing on higher platforms while camera scrolls upward. * Platform generation is procedural with guaranteed reachability; difficulty ramps with height. * Score = floors reached + combo bonuses. Lose if the camera overtakes the player from above or the player falls out of view. --- ## 2) Scoring and Combo System **Final Score:** ``` finalScore = 10 * highestFloorReached + Σ( comboTotalFloors^2 ) ``` * A **multi‑floor jump** is a landing at least **2 floors above** the previous floor (Δfloor ≥ 2). * A **combo** is a sequence of consecutive multi‑floor jumps without interruption. * A combo ends if you land with Δfloor < 2, the **combo timer** expires (\~3.0 s), or game over occurs. * A combo contributes to score only if it contains **≥ 2** multi‑floor jumps **and** ends cleanly (i.e., not directly by game over). * UI: a vertical combo meter on the left; refills on multi‑floor landings and decays linearly (tunable 2.5–3.5 s). --- ## 3) Physics & Controls (deterministic) ### 3.1 Simulation timing * **Fixed timestep**: 60 Hz (dt = 1/60 s). Rendering decoupled from simulation. * **Numeric model**: 32‑bit **fixed‑point Q16.16** for all core physics state (positions/velocities) to keep behavior identical across browsers. * **PRNG**: seedable (PCG32 or XorShift128+). The seed is stored in replays for deterministic regeneration. ### 3.2 Units & collisions * World units are pixels; reference resolution **480 × 720**. Scale the canvas, not the simulation. * Platforms are one‑way (pass from below, collide from above) with AABB tests. * Platform thickness: **12 px**. ### 3.3 Tunable constants (initial values) * Gravity `g = 2500 px/s²` * Horizontal accel ground/air `ax_ground = 2400`, `ax_air = 1600` * Max horizontal speed `vx_max = 520` * Ground friction (no input) `friction = 3000` * Base jump velocity `vy_jump_base = 900` (up is negative in equations) * Run‑up bonus `vy_run_bonus = 420 * clamp(|vx|/vx_max, 0..1)` * Early release (jump‑cut): if jump released while rising → `vy = vy * 0.55` * Coyote time `t_coyote = 80 ms` and input buffer `t_buffer = 100 ms` * Wall bump: on side collision `vx *= -0.88` with a brief stick (\~8 ms) for sharp turns ### 3.4 Controls * **←/→** apply horizontal acceleration (air control is weaker). * **Space** jumps; uses coyote time + input buffer for fairness; holding space allows higher jump unless cut early. --- ## 4) Camera & Auto‑scroll * Camera follows with a dead‑zone (\~30% of screen height from the bottom). * Auto‑scroll speed increases with height: `s(y) = s0 + stepGain * floors/Δ`. Start `s0 ≈ 140 px/s`, add \~+10 px/s every \~25 floors. * Anti‑camp: slight speed bump (+5–10%) after \~1.5 s of idling. * Game over if the camera’s top crosses >8 px above the player’s head. --- ## 5) Procedural Platforms (guaranteed reachability) **Parameters** * Initial width `w0 = 360 px` with jitter ±20 px; min/max width `w_min = 64 px`, `w_max = 400 px`. * Vertical gap increases with floor: `gap = lerp(72, 132, clamp(floor/500,0..1))` + noise ±8 px. * Horizontal offset per step: uniform in `[-180, +180]` clamped to walls (16 px margins). * Theme swap every 100 floors (visual only). **Algorithm (sketch)** 1. Set candidate `C` at next y using `gap(floor+1)`. 2. Sample width `w` by difficulty ramp and x with jitter. 3. **Reachability test** using worst‑case run‑up and jump; if unreachable, re‑roll up to K tries. 4. Fallback: insert an easier intermediate platform. --- ## 6) Deterministic Replays (serverless) * **Record**: `{ version, seed, settingsSubset, inputEvents[], startFloor }`, where `inputEvents` are time‑stamped press/release for ←, →, Space. * **Storage**: compact binary (delta‑times + bitmasks) then Base64 for sharing, or plain JSON for readability. * **Playback**: re‑simulate with the same fixed‑step and PRNG seed. * **Share**: encode replay to Base64 and place it in the **URL hash** (e.g., `#r=<b64>`), or export as a `.tcr` file. Import parses and plays without any network calls. * **Checksum**: optional rolling CRC/XOR every N ticks for quick integrity checks across imports. --- ## 7) Client‑side Persistence * **Local leaderboards**: keep top N (e.g., 50) scores overall + daily/weekly views (computed client‑side by date keys). Stored in LocalStorage/IndexedDB. * **Achievements**: boolean flags + progress counters in LocalStorage. * **Settings/skins**: store selected skin id, audio volumes, accessibility toggles. * **Import/Export**: one consolidated JSON blob (scores, achievements, skins, settings, replays). Users can share or back up this file manually. --- ## 8) Achievements (examples) 1. First Steps — reach floor 25 2. Heights — 100 3. Skyline — 250 4. Stratosphere — 500 5. Warm‑up — first valid combo 6. Acrobat — combo ≥ 12 total floors 7. Combo King — combo ≥ 25 total floors 8. Speedrunner — 100 floors in ≤ 45 s 9. Ice Dancer — 5 multi‑floor jumps without touching a wall 10. Wall Wizard — 5 quick wall‑turns in one run 11. No Chill — never let the combo meter empty after first activation for ≥ 30 s 12. High Roller — score ≥ 100,000 13. Perfectionist — no off‑screen falls for 3 min 14. Collector — unlock 5 skins 15. Daily Climber — top 10 **local** daily board 16. Comeback — recover from bottom 15% of the screen to a safe zone 17. Marathon — play 10 minutes in one run 18. One‑Take — no pause from start to game over 19. Tactician — 3 valid combos in a row 20. Artist — use a custom skin --- ## 9) UI/HUD * Left: combo meter (timer) + numeric “combo total floors”. * Top: score, current floor, auto‑scroll speed. * Right (optional dev overlay): FPS and simulation tick timing. * Menus: pause, settings, skin picker, replay browser (load/play/export/delete).
A system prompt was added to support web rendering