MadCap
A 2–8 player browser party game: short rounds in a tiny arena, physics shoves and fourteen modes. I built all of it, from the game simulation and netcode to the accounts, the art and the deploys. The hard part was making a real-time game feel instant over the internet.
Stack
- Language
- TypeScript everywhere: the same simulation runs on the client and the server
- Client
- Phaser 3 + Vite, DOM UI: a small, fast-loading 2D engine; menus stay HTML
- Physics
- Custom, in a shared package: everything is circles: deterministic, cheap, easy to sync
- Multiplayer
- Colyseus (Node): rooms, join codes, state sync and reconnection
- Data
- SQLite on the game server: profiles, accounts and the in-game currency, at no extra cost
- Hosting
- Cloudflare Pages + one VPS (Docker, Caddy): about $6 a month to run
- Tests
- Vitest + Playwright: the sim and server rules, plus end-to-end flows gating releases
Shape
browser (Cloudflare Pages) game server (VPS, Docker) input ─ seq-numbered inputs ──────────▶ room: fixed-step sim @ 30 Hz predict own player (shared sim) modes, modifiers, scores interpolate others ~100 ms behind ◀──── state patches @ 20 Hz
Notes
One simulation, three places
The game itself lives in a shared package that never imports Phaser or Colyseus: movement, dash impulses, mass-based collisions, falling off the arena, the fourteen modes and the modifiers that change a round halfway through (ice, wind, a shrinking floor). Modifiers are mostly parameter transforms, so ice is just less friction.
Because it is pure TypeScript, the same code runs on the server as the authority, in the browser for prediction, and in the browser alone for practice against bots, which needs no server at all.
Making it feel instant
The server is authoritative: it decides positions, knockouts and scores. The client predicts its own player with the shared sim and reconciles when the server answers, replaying the inputs the server has not seen yet. Everyone else is drawn about 100 ms in the past and interpolated, so they move smoothly.
Hits play their particles and sounds optimistically, but outcomes only come from the server. A ?lag= and ?jitter= switch simulates a bad network, and network bots can fill a room for testing.
Everything around the game
Guest profiles with no sign-up, optional accounts (Google, Discord or an emailed link, behind Cloudflare Turnstile), a currency earned by playing, cosmetics the server checks ownership of, a daily challenge, password-protected rooms with rate-limited guesses, and a staff page behind Cloudflare Access.
The last eight seconds of each round are kept in the browser, so you can rewatch one and save it as a video. Sound effects are synthesised in the browser, and the art is SVG.
Shipping it
Merging does not deploy. A release is a manual GitHub Actions run that first runs the end-to-end tests tagged as release-critical, then ships the client to Cloudflare Pages and a new container image to the game server. The server is named after its region, not its host, so moving providers never changes an address players use.