Skip to main content

Multiplayer Games Design

I am building fun, multi-player games that players can play together competitively on-chain, or off-chain by connecting P2P directly through WebRTC without a server.

WebRTC Multiplayer​

In the off-chain mode, players can start immediately and seamlessly, just by connecting and playing with family and friends directly via WebRTC.

In this setup, one client acts as both the server (or 'host') and a player. This host is responsible for the entire game state and logic. All other 'normal' clients connect directly to this host. The host's GameLogic component receives actions from all players (including itself), computes the next game state, and then broadcasts the update to everyone.

The server client (the host) will have three main components: Network, GameLogic, and GameUI. In contrast, the other clients only need the Network and GameUI components.

Alt text

  • Network: Sends and receives player actions and game state updates.
  • GameLogic (Host-only): Processes incoming actions to compute the next game state.
  • GameUI: Renders the current game state and captures player input (actions).

Here are the logic details

Alt text

This design applies on the current Monster game. My next games will follow this closely.

Onchain Multiplayer​

Leverage session keys / sub-accounts for seamless on-chain experiences.