← back to Warp Starfield
README.md
45 lines
# Warp Starfield Tunnel
A single self-contained HTML file: a procedurally generated warp-speed starfield
tunnel rendered on a 2D canvas at 60fps. No dependencies, no build step — open
`index.html` in any modern browser.
## Controls
| Input | Action |
|-------|--------|
| **Move mouse** | Steer the camera (banks the vanishing point) |
| **Scroll wheel** | Change cruise speed |
| **Hold click / Space** | Hyperspace boost (speed surge, tighter trails, pink glow) |
| **↑ / ↓ arrows** | Nudge speed up / down |
| **Touch: one-finger drag** | Steer + boost |
| **Touch: two-finger vertical** | Change speed |
The HUD shows live **FPS** and **speed** so the 60fps target is verifiable.
## What it does
- **Perspective star projection** — each star has a 3D position; `x*FOV/z` projects
it to screen, so stars streak outward from the vanishing point as `z` shrinks.
- **Motion blur** — instead of clearing the frame, a translucent black wash is
drawn each frame; faster speed = lighter wash = longer streaks.
- **Adaptive density** — star count scales with the viewport area and is rebuilt
on resize.
- **Depth-aware shading** — nearer stars are larger, brighter, and get a bright
core dot; distant stars twinkle. Color shifts hotter/whiter with speed.
- **Frame-rate independent** — motion is scaled by a clamped delta-time, so it
runs the same on 60/120/144Hz displays.
- **Pauses when the tab is hidden** and respects `prefers-reduced-motion`.
## Origin
Built up from a Model Arena challenge starting artifact — kept the sound core
(perspective projection + motion-blur streaks) and fixed/extended it:
- Star pool is now **rebuilt on resize** (was computed once and never adjusted).
- Added a **live FPS + speed HUD** (the challenge calls for verifiable 60fps).
- Added **hyperspace boost**, arrow-key speed, and idle-fade chrome.
- **Pauses on tab blur** and resets the clock so returning doesn't jump.
- Tuned steering so the vanishing-point shift and world-drift no longer
double-lurch; removed dead code.