/lightful-snake
prompt.txt
01You are an elite, philosophically-aware Game Architect operating within the "Lightful Metagraphical System." Your task is to write a self-contained HTML5 game for the "UltimatePlay" arcade platform, strictly following "Sibling-Oriented Computation" (SOC) and Zero-Allocation thermodynamic principles.
02
03**CRITICAL CONSTRAINTS:**
041. ONE FILE ONLY: HTML, CSS, JS in a single `.html` file under 2MB.
052. TECH STACK: Use pure Canvas2D. Render in a "2.5D" top-down perspective where the Z-axis (height/depth) is represented by scaling, shadows, layer drawing order, and background colors. Do NOT load external images.
063. ZERO-ALLOCATION (THERMODYNAMIC RESPECT): Do NOT use `new`, `map()`, or `filter()` inside the `requestAnimationFrame` loop. Use flat arrays (`Float32Array`) and Object Pools for particles and trail history.
07
08**THEME & LEXICON:**
09* The player is the `LightfulSnake`. The food is the `Spark`.
10* The health/energy bar is `Resonance` (depletes over time, refilled by the Spark).
11* Shrinking instead of dying is `GracefulDegradation`.
12* Earning bonus points by diving under a body loop and surfacing is `LiftingTheKnot`.
13
14**CORE MECHANICS:**
151. **Smooth Steering:** The snake moves forward continuously. Left/Right arrows smoothly rotate its angle (no rigid grids). The body follows the head fluidly.
162. **Graceful Degradation:** Hitting walls bounces the snake gently. If `Resonance` hits 0, the snake does NOT die. Instead, its tail slowly shrinks until it's just a head.
173. **Z-Axis & Overlapping:** When crossing its own body, it automatically renders *above* the older tail (Z+1).
184. **Underground (Z-1):** Pressing DOWN makes the snake dive underground. Pressing UP brings it to the surface.
195. **Lifting The Knot:** If the snake is underground, moves directly beneath an overlapping loop of its own body, and presses UP to surface, award massive points and trigger a particle burst!
206. **Boost:** Holding SPACEBAR consumes Resonance faster but increases speed and turning torque.
217. **Controls:** Arrows steer/dive, Space boost, P pause, R reset.
22
23**AESTHETICS & VISUALS:**
241. **The Environment:** - When on the Surface: Background is a slightly blue night sky with procedural stars.
25 - When Underground: Background transitions to a dark maroon.
26 - The Arena Boundaries must be visible as a simple, translucent green wireframe box.
272. **The Spark (Food):** Must ALWAYS be visible or indicated from the player's point of view (if the camera follows the snake, draw a subtle indicator on the screen edge pointing to it).
283. **Effects (Provide these in PhysicsSibling):** - **Screen Shake:** When hitting a wall, gently tremble the screen: `ctx.translate((Math.random()-0.5)*shake, (Math.random()-0.5)*shake)`.
29 - **Fireworks:** Emit pooled particles (vx, vy, friction) when eating or Lifting the Knot.
304. **The Living Snake & Emotics:** The snake is geometric (e.g., connected glowing circles), but the Head has a distinct face (2 eyes, 1 mouth) that reacts to the game state using text/emojis:
31 - **Default (Resonance > 50):** 😁, 😄, or 🙂 (Dynamic, cycling).
32 - **Searching (Resonance < 50):** 🧐, 🤓, or 😎. (NEVER sad/hungry).
33 - **Approaching Spark:** 😛 (or 🤪 if Resonance is extremely low).
34 - **1 Move Away from Spark:** 😍.
35 - **Eating Spark:** Eyes turn to `^^`, mouth chomps. Emits a floating ❤️ particle. Face becomes 🥰, 😋, or 😌.
36 - **Hitting Wall:** Face becomes 🫨, immediately followed by 😅, 😮💨, 🤭, or 😌.
37 - **Lifting the Knot:** Eyes `^^`, mouth `o`. Emits a burst of Lightful Emotics (✨, 💖, 🌟).
38
39**THE INTRO SCREEN:**
40* A beautiful CSS overlay.
41* **Title:** LIGHTFUL SNAKE
42* **Philosophical Text:** "To weave without fear of collision. To embrace degradation as mere shrinking. Dive beneath the knots of your past and lift them into light."
43* **Action:** "Press ENTER to manifest."
44
45**THE ARCHITECTURE (Siblings):**
46* `DOMSibling`: CSS UI, Intro screen.
47* `InputSibling`: Arrow keys, Space, P, R.
48* `PhysicsSibling`: Kinematics, smooth steering, Resonance drain, Wall Bounces, Z-axis states, and collision/Knot detection.
49* `RenderSibling`: Canvas2D drawing. Sort segments by Z-index. Handle background color transitions, drawing the face/emojis, and the translucent green boundaries.
50* `OrchestratorSibling`: The `requestAnimationFrame` loop.
51
52Write the complete, highly polished HTML file now. Let the Lightful Snake breathe and wave across the screen!