gitflarePublicPartly agent-ready40
neon-drift
Real-time multiplayer arcade racer on Cloudflare Workers and Durable Objects.
- LicenseApache-2.0
- LanguageJavaScript
- Last landed
3efe3daOct 23, 2026
3efe3daNeon Drift
Real-time light-cycle battle royale (2–16 players) on one Cloudflare Worker + Durable Objects.
Run
npm install, npm run dev, npm test, npm run bots -- <baseUrl> --bots 8.
How to play
Steer with ← → / A D, boost with Space. On touch hold the left/right half to turn; double-tap or use two fingers to boost. Touching any trail or leaving the shrinking arena eliminates you; kills +50, orbs +10, survival +1/s.
Architecture
src/index.tsroutes;src/room.tsRoom DO (30 Hz authoritative, hibernation WebSockets);src/lobby.tsroom registry;src/leaderboard.tsD1 (graceful without DB).public/shared/sim.jsdeterministic simulation shared by server and client prediction.public/net.jsprediction, reconciliation, interpolation;render.js,fx.js,audio.js,input.jspresentation;app.js+ui-helpers.jslanding page and HUD. CSP inpublic/_headers.
Protocol (compact JSON arrays)
Client: ["j",name,token,tick], ["i",seq,turn,boost,ackTick], ["a",tick], ["p",ms].
Server: ["w",...] welcome, ["s",tick,baseTick,seq,delta] snapshot with appended trail points only, ["o",...] pong, ["v",tick,...events] batched events, ["e",code,msg].
Routes
/health, POST /api/rooms, /api/quickplay, /api/leaderboard?mode=arena, /ws/<CODE>, /r/<CODE>.
Local development
npm run devstartswrangler dev. The leaderboard creates its table on first use, so local D1 works without setup; you can also runwrangler d1 migrations apply DB --local.- UI flow:
/is the landing page only;/r/<code>shows a compact join sheet over a blurred live view (the client joins watch-only, join field 5 = 1, then sends a normal join on the same socket). - UI files:
public/app.js(bootstrap + HUD),public/index.html,public/style.css,public/_headers(CSP),public/ui-helpers.js(pure helpers),src/index.ts,src/lobby.ts,src/leaderboard.ts.
How to play
Ride a light cycle, leave a trail, and avoid every trail (and the arena edge). Grab orbs for points and boost, take kills for +50, and outlast the shrinking arena. Last rider wins; matches restart automatically.
Controls
- Keyboard: ← → or A D steer, Space boosts. M-style mute button in the HUD (remembered).
- Touch: hold the left or right half to turn, double-tap or two-finger hold to boost.
Architecture
browser (app.js, render.js, net.js, input.js)
│ WebSocket (JSON messages)
Worker (src/index.ts) ──► Room Durable Object (src/room.ts, shared sim public/shared/sim.js)
│ └─ 30 Hz tick, snapshots + event batches
└─► Lobby DO / Leaderboard (D1)
Protocol summary
Client → server: inputs (turn, boost, seq, ack tick), ["a", tick] acks, pings. Server → client: welcome, snapshots (full then deltas), ["v", tick, ...events] event batches. Excess traffic earns strikes; 3 strikes close with 1008.
Performance (measured)
| Metric | Value |
|---|---|
| Client fps, 16 players | TBD |
| Snapshots/s per client | TBD |
| Mean delta snapshot size | TBD |
| 16-player sim step | TBD |
Measured performance
| Metric | Device | Result |
|---|---|---|
| Client FPS | TBD | TBD |
| Snapshot size (bytes) | TBD | TBD |
| RTT (ms) | TBD | TBD |