Katballe Studio Writing Projects About

Drift Party

active
Cloudflare WorkersDurable ObjectsWebSocketsCanvasTypeScriptGame

A party racer where the big screen is the track and every phone is the controller. Open the game on a TV or laptop, and up to eight players join by scanning a QR code or typing a six-character room code — the screen just hosts, and empty seats can be filled with bots at three skill levels. Pick one of seven cars — from a nimble go-kart to a monster truck that shrugs off sand, or a heavy bus that shoves everyone aside — ready up, and race one of five hand-drawn tracks, or play the Cup: all five in a row, with points after every race.

The tracks are built for close racing: boost pads, a slipstream when you tuck in behind someone, oil slicks, sand traps, a sheet-ice track, and a gentle catch-up for whoever's trailing. Checkpoints sit only at each track's key corners, found automatically from the shape of the road.

The interesting part is the networking. Phones and screen never talk directly: each opens a WebSocket to a single Cloudflare Worker, and a Durable Object acts as the room — assigning player slots, tagging each phone's inputs, and relaying gas/brake/steer to the screen at the edge. A phone that drops (a locked screen, a flaky connection) gets its own car back when it reconnects, and the host can refresh without losing the room. Because everything flows through the Worker instead of peer-to-peer, it works across any network with nothing to install. Idle rooms hibernate, so they cost nothing when no one's playing.

The whole thing is one deployable: a Vite + TypeScript front-end (a fixed-step simulation and canvas renderer for the screen, multi-touch controls for the phone) served as static assets by the same Worker that hosts the rooms, with a headless test suite that drives full eight-car races on every track — and checks all seven cars lap within a few percent of each other — before each deploy.