Skip to content

aasoni/blackholio-ts

Repository files navigation

Blackholio

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.

Try it out!

The game is live here if you want to give it a try.

Structure

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.

Controls

  • Move: arrow keys or WASD
  • Respawn after death: Space

Running locally

1. Start SpacetimeDB

spacetime start

2. Publish the module

pnpm spacetime:publish:local

Or manually:

spacetime publish -s local blackholio --module-path spacetimedb

3. Generate TypeScript bindings

pnpm spacetime:generate

Run this any time you change the server schema or reducers.

4. Install dependencies and start the client

pnpm install
pnpm dev

Open http://localhost:5173, enter a name, and click Play.

Deploying to SpacetimeDB maincloud

1. Log in

spacetime login

2. Publish the module

pnpm spacetime:publish

3. 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

Environment variables

Variable Default Description
VITE_SPACETIMEDB_HOST ws://localhost:3000 SpacetimeDB server URL
VITE_SPACETIMEDB_DB_NAME blackholio Database name

About

An agar.io-style multiplayer game built with SpacetimeDB, Phaser, and TypeScript.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors