|
| 1 | +# Blackholio Phaser Client |
| 2 | + |
| 3 | +Browser client for the existing Blackholio Rust SpacetimeDB module, built with |
| 4 | +TypeScript and Phaser. |
| 5 | + |
| 6 | +## Requirements |
| 7 | + |
| 8 | +- Node.js 18 or later |
| 9 | +- pnpm 10.16.0 or later |
| 10 | +- A locally available SpacetimeDB CLI/server |
| 11 | + |
| 12 | +This is a standalone pnpm project. Its local `pnpm-workspace.yaml` prevents |
| 13 | +pnpm from selecting the repository workspace, and its local dependency |
| 14 | +configuration enforces a 1440-minute minimum release age. |
| 15 | + |
| 16 | +The checked-in dependency configuration links the TypeScript SDK from this |
| 17 | +repository during development: |
| 18 | + |
| 19 | +```json |
| 20 | +"spacetimedb": "link:../../../crates/bindings-typescript" |
| 21 | +``` |
| 22 | + |
| 23 | +When publishing this demo outside the SpacetimeDB repository, replace the local |
| 24 | +link with the current published npm package version: |
| 25 | + |
| 26 | +```json |
| 27 | +"spacetimedb": "<latest-published-version>" |
| 28 | +``` |
| 29 | + |
| 30 | +`package.json` does not support commented dependency alternatives, so the |
| 31 | +published form is documented here rather than left as an invalid commented |
| 32 | +entry in the manifest. |
| 33 | + |
| 34 | +## Run Locally |
| 35 | + |
| 36 | +Start the existing Rust server using its normal development workflow, then |
| 37 | +from this directory: |
| 38 | + |
| 39 | +```bash |
| 40 | +pnpm install |
| 41 | +pnpm dev |
| 42 | +``` |
| 43 | + |
| 44 | +To regenerate this client's checked-in TypeScript bindings without changing |
| 45 | +the server project: |
| 46 | + |
| 47 | +```bash |
| 48 | +spacetime generate --lang typescript --out-dir src/module_bindings --module-path ../server-rust |
| 49 | +``` |
| 50 | + |
| 51 | +## Source Layout |
| 52 | + |
| 53 | +The client follows the same controller boundaries as the Unity example: |
| 54 | + |
| 55 | +- `GameManager.ts`: SpacetimeDB connection, subscriptions, and entity/player registries |
| 56 | +- `PlayerController.ts`: local input and owned-circle state |
| 57 | +- `EntityController.ts`, `CircleController.ts`, and `FoodController.ts`: rendered entities |
| 58 | +- `CameraController.ts`: center-of-mass following and zoom |
| 59 | +- `ui/`: username chooser, death screen, leaderboard, and browser HUD |
| 60 | + |
| 61 | +The client connects to `ws://localhost:3000` and database `blackholio` by |
| 62 | +default. Override either value when starting Vite: |
| 63 | + |
| 64 | +```bash |
| 65 | +VITE_SPACETIMEDB_HOST=ws://localhost:3000 \ |
| 66 | +VITE_SPACETIMEDB_DB_NAME=blackholio \ |
| 67 | +pnpm dev |
| 68 | +``` |
| 69 | + |
| 70 | +## Controls |
| 71 | + |
| 72 | +- Pointer: steer |
| 73 | +- `Space`: split |
| 74 | +- `Q`: lock or unlock steering direction |
| 75 | +- `S`: self-destruct |
0 commit comments