Build a collaborative canvas game
This tutorial walks you through building a multiplayer pixel canvas on Crowded Kingdoms — step by step, with a live demo for each chapter.
What you'll build
- Auto guest login on first visit (no login form), then an app-scoped token minted before gameplay
- Mouse-controlled dot as your actor in the world
- Click to paint ground cells that persist in the game database
- Viewport edge scroll when you reach the window boundary
- Collaborative viewport push — multiple players coordinate to pan the shared window
The companion demo app lives in the simple-web-demo repository. Each chapter maps to an interactive route.
Run the interactive demo
From the monorepo (requires the CrowdyJS repo as a sibling of simple-web-demo):
cd simple-web-demo
npm install
npm run dev
Open http://127.0.0.1:5180 — enter your env handle in the config bar, or jump straight to the full canvas.
From the docs repo:
npm run demo:install # first time
npm run demo:dev
Verify docs are sufficient
The demo's Playwright suite exercises every chapter against the live dev tier. If it passes, the docs and APIs cover everything needed to build the game:
cd simple-web-demo && npm run verify
# or from cks-docs:
npm run demo:verify
| Chapter | Demo route |
|---|---|
| 1 — Project setup | http://127.0.0.1:5173/chapter/1 |
| 2 — Auto guest auth | http://127.0.0.1:5173/chapter/2 |
| 3 — Connect & bootstrap | http://127.0.0.1:5173/chapter/3 |
| 4 — Canvas coordinates | http://127.0.0.1:5173/chapter/4 |
| 5 — Actor presence | http://127.0.0.1:5173/chapter/5 |
| 6 — Painting voxels | http://127.0.0.1:5173/chapter/6 |
| 7 — Viewport edge scroll | http://127.0.0.1:5173/chapter/7 |
| 8 — Collaborative viewport | http://127.0.0.1:5173/chapter/8 |
| 9 — Full game | http://127.0.0.1:5173/chapter/9 |
| Canvas (full game) | http://127.0.0.1:5180/canvas |
| Tanks (multiplayer demo) | http://127.0.0.1:5180/tanks |
Prerequisites
- Node.js 20+
- A modern browser
- No org membership required for the dev tier
Fixed dev-tier configuration
All chapters use these values:
ManagementApiUrl=https://api.dev.crowdedkingdoms.com
GameApiHttpUrl=https://game.shared.dev.cks-env.com/graphql
GameApiWsUrl=wss://game.shared.dev.cks-env.com/graphql
AppId=<your-app-id>
Create your own app on dev and use its appId, or follow the tutorial's seeded demo app if provided.
See also Dev tier (client integration).
Chapters
- Project setup — connectivity and config
- Auto guest auth — register, then mint an app-scoped token
- Connect & bootstrap — app token → UDP proxy
- Canvas coordinates — world → chunk/voxel
- Actor presence — mouse → dot
- Painting voxels — click to color
- Viewport edge scroll — pan the window
- Collaborative viewport — push together
- Full game — assembly
Reference pages: