Skip to content

Gravy

A small multiplayer top-down game. Friends share one flat, cook dishes at the stations (vegetables, soup, roast, bread, salad) and serve them to the guests at the table. Everyone plays in the same kitchen, with one shared game state.

Layout

  • src/ Rust (actix-web). Owns the game state, runs the simulation at 15 ticks per second, and serves the built client.
    • src/world.rs players, stations, guests, rounds and the tick step
    • src/map.rs the flat as a character grid (the single source for layout)
    • src/api.rs HTTP handlers and the SSE stream
  • client/ Phaser 4 client, built with bun and Vite.
    • src/flat.js renders the map and the latest snapshot
    • src/hud.js round status, orders, what you're holding, the log
    • src/controls.js keyboard, on-screen stick and the Use button
    • src/join.js name and look screen
  • Dockerfile builds the client, then the server, into one image.
  • docs/v1-screenshots/ screenshots of the first, single-player version.

API

MethodPathPurpose
GET/api/mapThe flat as rows of characters (once, at start)
POST/api/join{name, look} → {id} (409 if the flat is full)
POST/api/input{id, dx, dy}: the current direction (also the heartbeat)
POST/api/action{id}: use the tile you're facing
POST/api/leave{id}
GET/api/eventsSSE stream: event: state (15/s snapshot) and event: log

Players who send nothing for 10 seconds are removed. The client reloads when the server no longer knows its id.

The id returned by /api/join is the only credential, so keep it out of logs.

Playing

  • Arrows / WASD, or the stick on a phone, to move. Space, E, or Use to act.
  • Take food from the crates and fridge, chop it on the board, cook soup in the pot and roast in the oven, toss salad in the bowl.
  • Carry a finished dish to a guest's chair. Each guest wants two dishes.
  • A dinner lasts four minutes. When everyone has eaten, or time runs out, the next one starts after a short pause.

Run locally

Requires bun 1.4.4 and a recent stable Rust.

# terminal 1: the server on :8080
PORT=8080 STATIC_DIR=client/dist cargo run

# terminal 2: the client dev server on :5173, proxying /api to :8080
cd client && bun install && bun run dev

Open http://localhost:5173. To test on a phone on the same network, open the "Network" address Vite prints (the dev server listens on all interfaces).

In production the server serves the bundle itself: open http://localhost:8080.

Server tests: cargo test. Live multiplayer test (needs a running server): BASE=http://127.0.0.1:8080 bun test tests/multiplayer.test.js.

Container

docker build -t gravy:local .
docker run --rm -p 8080:80 gravy:local

Configuration is by environment: PORT (80 in the image), BIND_ADDRESS (0.0.0.0 in the image), STATIC_DIR (/app/static in the image), and RUST_LOG.