An agar.io-style multiplayer game built with SpacetimeDB, Phaser, and TypeScript.
Players are circles on a 2000x2000 grid. Move around to eat food (small gray circles) to grow larger. Run into a smaller player to eat them. If a larger player overlaps you enough, you get eaten and respawn.
The game is live here if you want to give it a try.
spacetimedb/ SpacetimeDB module (server-side game logic)
src/ Phaser client (frontend)
The module runs a game loop at 20 ticks per second. It handles movement, collision, food spawning, and player eating. The client connects to SpacetimeDB and renders the game state using Phaser.
- Move: arrow keys or WASD
- Respawn after death: Space
1. Start SpacetimeDB
spacetime start2. Publish the module
pnpm spacetime:publish:localOr manually:
spacetime publish -s local blackholio --module-path spacetimedb3. Generate TypeScript bindings
pnpm spacetime:generateRun this any time you change the server schema or reducers.
4. Install dependencies and start the client
pnpm install
pnpm devOpen http://localhost:5173, enter a name, and click Play.
1. Log in
spacetime login2. Publish the module
pnpm spacetime:publish3. Set environment variables
Create a .env.local file:
VITE_SPACETIMEDB_HOST=wss://maincloud.spacetimedb.com
VITE_SPACETIMEDB_DB_NAME=your-database-name
4. Generate bindings and start the client
pnpm spacetime:generate
pnpm dev| Variable | Default | Description |
|---|---|---|
VITE_SPACETIMEDB_HOST |
ws://localhost:3000 |
SpacetimeDB server URL |
VITE_SPACETIMEDB_DB_NAME |
blackholio |
Database name |