Skip to content

gitflarePublicPartly agent-ready40

sketch-rush

Multiplayer draw-and-guess game on Cloudflare Workers, Durable Objects and D1.

main
Add the Apache-2.0 licencedbe1e99
Markdown27 lines1.6 KB

Sketch Rush

Draw-and-guess party game (3–12 players) on one Cloudflare Worker + Durable Objects.

How to play

Quick play or create a private room and share the invite link. Each turn the drawer picks one of 3 words and draws it (80 s); others guess in chat. Faster guesses score more; the drawer earns points per correct guess. 3 rounds, then a podium and an automatic new game.

Run

npm install, npm run dev, npm test, npm run bots -- http://localhost:8787 --bots 4.

Architecture

  • src/index.ts routes (/health, /api/rooms, /api/quickplay, /api/leaderboard, /ws/<CODE>); src/room.ts Room DO (30 Hz alarm tick, hibernating WebSockets); src/lobby.ts room directory; src/leaderboard.ts D1 (optional).
  • public/shared/sim.js deterministic rules; protocol.js codecs.
  • Client: app.js UI, net.js, render.js, input.js, tools.js, audio.js, fx.js, ui-helpers.js (pure helpers).

Protocol

Client: ["j",name,token,tick], ["d",seq,strokeId,color,size,...xy], ["u",seq], ["c",seq], ["g",seq,text], ["w",seq,idx], ["a",tick], ["p",ms]. Server: ["w",...] welcome, ["s",...] delta snapshot, ["k",epoch,fromOp,...ops] shared stroke ops, ["v",tick,...events] batched events, ["o",...] pong, ["e",code,msg]. Rate limit: token bucket 60/s, burst 90; 3 strikes close with 1008.

Security

CSP in public/_headers; all user text is rendered with textContent.

Local D1

src/leaderboard.ts creates the scores table on first use, so wrangler dev works as is. To apply migrations explicitly: wrangler d1 migrations apply DB --local.