Game Patterns

Watchtower gives you primitives. Here's how to build common game types.

Every multiplayer game follows a pattern for syncing state. Pick the one that fits your game:

Patterns

Choosing a Pattern

PatternAuthorityUpdate RateComplexity
Cursor PartyNone (peer-to-peer)High (20-60Hz)
Turn-BasedHostLow (on action)⭐⭐
Action GameNone or HostHigh (20Hz)⭐⭐⭐
Chat RoomNoneLow (on message)

Common Concepts

Host Authority

In turn-based and some action games, the host (first player to join) controls the "true" game state. Other players send requests, and the host validates and broadcasts the result.

if (room.isHost) {
  // I control the game state
  room.broadcast({ type: 'state', ...gameState })
}

Client-Side Smoothing

For action games, you'll want to smooth movement between network updates. The simplest approach is lerping:

const LERP = 0.15

function update() {
  for (const p of Object.values(players)) {
    p.x += (p.targetX - p.x) * LERP
    p.y += (p.targetY - p.y) * LERP
  }
}

Message Timestamps

Every message includes meta.serverTime and meta.tick. Use these for ordering messages or building more sophisticated interpolation.