A game project built with a monorepo architecture.

Overview

Dodge Tanks is a tank-based game where players must dodge incoming obstacles and enemies.

Architecture

This project uses a monorepo structure to organize related packages and applications:

/ 
├── packages/
   ├──common/       # Shared packages and libraries (pure ts)
   ├──client/       # Client code (Phaser game)
   ├──server/       # Server code (Colyseus)

Key Components

- **Monorepo Structure**: Centralized codebase for easier dependency management and code sharing

- **Modular Design**: Separation of concerns between game logic, rendering, and utilities

- **Shared Packages**: Reusable components across different parts of the application

Multiplayer Architecture

Server Authoritative

The game uses a server-authoritative architecture where:

- All game state is managed and validated on the server

- The server is the single source of truth for player positions, collisions, and game events

- Clients send inputs to the server, not direct state changes

- Prevents cheating and ensures consistent gameplay across all clients

Client Prediction

To maintain responsiveness despite network latency:

- Clients predict the outcome of their inputs locally

- Players see immediate feedback for their actions

- Predictions are later reconciled with authoritative server state

Server Reconciliation

When client predictions diverge from server state:

- Server sends authoritative updates to clients

- Smooth corrections prevent jarring visual jumps

- Ensures eventual consistency between client and server

- [TODO] Clients replay unacknowledged inputs from the corrected state 


Leave a comment

Log in with itch.io to leave a comment.