Skip to content

LaibaFirdouse/MultiplayerGame

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Multiplayer Wave Survival Game Backend

Overview

This project is a real-time multiplayer backend for a cooperative survival game.

Players join a room, wait in a lobby, and then survive waves of enemies together. The system is designed to handle multiple rooms with many concurrent players.


Features

  • Room-based multiplayer (max 50 players per room)

  • 30-second lobby countdown before game start

  • Cooperative gameplay (players vs enemy waves)

  • 2 waves of enemies (10 enemies each)

  • Increasing difficulty per wave

  • Real-time state updates using WebSockets

  • Group-based result:

    • WIN → at least one player survives all waves
    • LOSE → all players die

Game Flow

Join Room → Lobby (30s) → Game Start → Waves → Result

Core Events

Client → Server

  • JOIN_ROOM

Server → Client

  • JOIN_SUCCESS → returns roomId
  • LOBBY_TIMER → countdown updates
  • GAME_START → game begins
  • GAME_STATE_UPDATE → real-time state
  • PLAYER_ELIMINATED → player dies
  • GAME_END → WIN / LOSE

Project Structure

game-backend/
├── src/
│   ├── server.js
│   ├── gateway/
│   │   └── socketHandler.js
│   ├── rooms/
│   │   ├── room.js
│   │   └── roomManager.js
│   ├── game/
│   │   └── gameEngine.js
│
├── public/
│   └── index.html
│
├── package.json
└── README.md

Tech Stack

  • Node.js
  • Socket.IO
  • HTML Canvas (for demo UI)

Run Locally

npm install
node src/server.js

Open:

public/index.html

How to Test

  • Open multiple tabs in browser

  • Each tab = one player

  • Observe:

    • lobby countdown
    • wave progression
    • player elimination
    • final result

Design Choices

Why 50 players per room?

  • Balances performance and gameplay
  • Avoids heavy CPU/network load
  • Ensures smooth real-time updates

Why server-authoritative?

  • Single source of truth
  • Prevents inconsistent state
  • Simplifies synchronization

Notes

  • Players cannot join after game starts
  • New players are assigned to a new room
  • Game runs entirely in memory for speed

Implementation Notes

This project demonstrates:

  • Room-based player grouping
  • Real-time state synchronization
  • Tick-based simulation loop
  • Wave-based enemy system
  • Controlled game lifecycle (lobby → game → end)

The implementation validates a scalable and maintainable multiplayer backend design.


Future Improvements

  • Add player-controlled movement
  • Add projectile-based combat
  • Add reconnect handling
  • Add distributed state (Redis)
  • Add matchmaking strategies

Author

Laiba Firdouse

About

No description, website, or topics provided.

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors