Multiplayer RTS Dedicated Game Server written in NodeJS for a small-scale game.
Approach
- Client send their Inputs/State
- Server pushes client requests in a FIFO approach
- Server update game state in each tick (gameserver may ideally have a tick rate of say 10, i.e 100ms are allocated for each tick)
- Server also builds a cumulativeUpdate packet (delta updates)
- Server send back delta updates (stored in cumulativeUpdate array) back to all clients
This is a timestep based approach that makes sure server only send delta updates back to all clients instead of whole game state.
Both the GIFs shows basic boid avoidance behaviour
- Build the client side code, this includes phaser related code that is used to draw/render game on the browser.
npm run build
- Once done, simply run the server.
npx ts-node server.ts
- Check the port where server is running and you're good to go.
- Create game room
- open another window on same url, click on join room (it may take few seconds)