A multiplayer Pong game built with Rust + WebAssembly (client) and Cloudflare Durable Objects (server).
cargo install wasm-pack # Prerequisites: Rust, Node 20+
npx wrangler login # One-time Cloudflare auth
npm run build && npm run dev # http://localhost:8787| Mode | How |
|---|---|
| Multiplayer | Click CHALLENGE → share link → JOIN |
| VS AI | Click PLAY |
Controls: Arrow keys or W/S · Touch on mobile
Rules: First to 5. Hit position affects ball trajectory.
See ARCHITECTURE.md for the system diagram and component deep dive.
Key design decisions:
- Shared
game_core— The same deterministic physics runs the offline game and the authoritative server - Binary protocol — Minimal
postcardserialization over WebSocket - Durable Objects — Each match is a stateful instance with 60Hz game loop
- Installable PWA — A service worker caches the app shell, so the menu and VS-AI game work offline; an in-app prompt offers updates
pongo/
├── game_core/ # Game logic (plain structs) — shared by client/server
├── proto/ # Network protocol (postcard)
├── client_wasm/ # Canvas2D renderer + client
├── server_do/ # Durable Object server
├── lobby_worker/ # HTTP routing + static front-end (PWA)
└── worker/ # Built WASM + assets
npm run build # Build WASM
npm run dev # Local server
npm run test # Run tests
npm run test:all # Full pre-push gate (prettier, fmt, check, clippy, tests, diagrams)
npm run deploy # Deploy to Cloudflare| Issue | Fix |
|---|---|
| Build fails | cargo install wasm-pack |
| Port in use | Kill process or edit wrangler.toml |
| Reset state | Delete .wrangler/state/ |
See ARCHITECTURE.md for technical details and game constants.
- AGENTS.md — workflow, verification gate, architecture rules, and code map (start here).
- docs/STATE_MACHINE.md — the client finite state machine.
- docs/BACKLOG.md — known limitations and forward-looking work.
MIT
