Skip to content

SaurabPoudel/IronTick

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Multiplayer Deterministic 2D Strategy Game

A production-quality Rust project implementing a multiplayer deterministic 2D strategy game with authoritative server architecture.

Architecture

  • Authoritative Server: Maintains full game state, processes commands deterministically
  • Client-Side Prediction: Smooth gameplay with rollback reconciliation
  • Fixed Timestep Simulation: 60 ticks per second for deterministic behavior
  • Custom Binary Protocol: Compact serialization without JSON overhead

Project Structure

├── shared/          # Shared library crate
│   ├── math.rs      # Fixed-point math for determinism
│   ├── protocol.rs  # Binary protocol definitions
│   └── tick.rs      # Tick timing utilities
├── server/          # Server binary
│   ├── main.rs      # Entry point
│   ├── net.rs       # Tokio-based networking
│   ├── simulation.rs# Deterministic game simulation
│   ├── world.rs     # World state management
│   └── protocol.rs  # Protocol re-export
└── client/          # Client binary
    ├── main.rs      # Entry point with Bevy
    ├── net.rs       # TCP networking
    ├── render.rs    # Bevy rendering
    ├── input.rs     # Input handling
    └── protocol.rs  # Protocol re-export

Features

  • Fixed-Point Math: Deterministic arithmetic using integer-based fixed-point numbers
  • State Snapshots: Full state synchronization every 10 ticks
  • Delta Updates: Efficient per-tick incremental updates
  • Command Buffering: Per-tick command queuing for deterministic replay
  • Checksum Verification: Desync detection via state checksums
  • Client Prediction: Local simulation with server reconciliation

Protocol Messages

Type Description
Handshake Client authentication
HandshakeAck Server acknowledgment with player ID
InputCommand Player movement/stop commands
StateSnapshot Full world state
DeltaUpdate Incremental state changes
Ping/Pong Latency measurement

Building

cargo build --release

Running

Terminal 1 - Start server:

./target/release/server

Terminal 2 - Start client:

./target/release/client

Controls

  • Right Click: Move selected units to cursor position
  • S: Stop all units
  • A: Clear selection

Configuration

Server address: 127.0.0.1:7777 (configurable in client/src/main.rs)

Technical Details

Determinism

  • All simulation uses fixed-point arithmetic (1000 scale factor)
  • No floating-point operations in game logic
  • Identical tick processing on server and client

Networking

  • TCP-based reliable communication
  • Length-prefixed binary packets
  • Non-blocking client I/O with threaded networking

Simulation

  • 60 ticks per second (16.67ms per tick)
  • Unit speed: 100 units/second
  • World size: 800x600

About

A production-quality Rust project implementing a multiplayer deterministic 2D strategy game with authoritative server architecture.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages