A production-quality Rust project implementing a multiplayer deterministic 2D strategy game with authoritative server 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
├── 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
- 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
| 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 |
cargo build --releaseTerminal 1 - Start server:
./target/release/serverTerminal 2 - Start client:
./target/release/client- Right Click: Move selected units to cursor position
- S: Stop all units
- A: Clear selection
Server address: 127.0.0.1:7777 (configurable in client/src/main.rs)
- All simulation uses fixed-point arithmetic (1000 scale factor)
- No floating-point operations in game logic
- Identical tick processing on server and client
- TCP-based reliable communication
- Length-prefixed binary packets
- Non-blocking client I/O with threaded networking
- 60 ticks per second (16.67ms per tick)
- Unit speed: 100 units/second
- World size: 800x600