Skip to content

Multiplayer RTS Game Server written in NodeJS . The project serves 2 purpose, first my love for RTS games, 2nd me trying to see how much performance i can squeeze out of nodejs server. Hosted on railway.app, Check out the url below (the url may need some 2-3 refreshes, as it takes a while for the server to spin up from sleep)

Notifications You must be signed in to change notification settings

keshav2010/RTSMultiplayerPOC

Repository files navigation

RTSMultiplayerPOC

Node.js CI

Multiplayer RTS Dedicated Game Server written in NodeJS for a small-scale game.

Approach

  1. Client send their Inputs/State
  2. Server pushes client requests in a FIFO approach
  3. 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)
  4. Server also builds a cumulativeUpdate packet (delta updates)
  5. 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.

Preview (Debug info is displayed for each unit)

Image from Gyazo

Both the GIFs shows basic boid avoidance behaviour Image from Gyazo

Getting Started

  1. Build the client side code, this includes phaser related code that is used to draw/render game on the browser.

npm run build

  1. Once done, simply run the server.

npx ts-node server.ts

  1. Check the port where server is running and you're good to go.
    1. Create game room
    2. open another window on same url, click on join room (it may take few seconds)

About

Multiplayer RTS Game Server written in NodeJS . The project serves 2 purpose, first my love for RTS games, 2nd me trying to see how much performance i can squeeze out of nodejs server. Hosted on railway.app, Check out the url below (the url may need some 2-3 refreshes, as it takes a while for the server to spin up from sleep)

Topics

Resources

Stars

Watchers

Forks