Multiplayer 2D shooter demo made using:
- Phaser - Game framework
- Hathora Cloud SDK - Server hosting
- Hathora Buildkits - Network transport
- React - Lobby UI
Assets from Kenney
Additional implementations of the game client are also available for the following engines:
The game is playable at https://bullet-mania.vercel.app
Lobby | Gameplay |
---|---|
Instructions:
- WASD to move
- Mouse to aim and shoot
- Spacebar to dash
- R to reload
- Once you are in a game, share the URL to allow others to join
Fully server authoritative game:
- Client sends user inputs to server
- Server processes the inputs and runs game simulation (at 20fps)
- Server broadcasts state snapshots to clients (at 20fps)
- Client interpolates the state snapshots and renders the game UI (at 60fps)
- No prediction on the client side
Room based architecture:
- One player creates a game session and gets back a
roomId
- They send the
roomId
to others - Others can join the same session with this
roomId
To run locally:
- Have node installed
- Get a Hathora
appId
andappSecret
via https://console.hathora.dev/ - Get a Hathora developer token (see https://hathora.dev/docs/guides/generate-developer-token)
- Create a .env file at the root with
HATHORA_APP_ID=<appId>
HATHORA_APP_SECRET=<appSecret>
DEVELOPER_TOKEN=<appToken>
- Start server: inside
server
directory runnpm start
(remember tonpm install
first) - Start client: inside
client
directory runnpm start
(remember tonpm install
first)
Server:
- Run
hathora-cloud deploy --appId <appId> --roomsPerProcess 1 --planName tiny --transportType tls --containerPort 4000 --env '[{"name": "DEVELOPER_TOKEN", "value": "<developerToken>"}]'
Client:
- cd to
common
and runnpm install && npx tsc
- Then cd to
client
andnpm run build
- Now you can deploy
dist
to any CDN like Vercel or Netlify