Build an online multiplayer game using peer-to-peer and realtime messaging

Coping with quarantine by coding!

What is pub/sub and how can I use it to build a game?

What is Peer-to-Peer and why is it helpful here?

an illustration of a peer to peer and a client server network
  • No need for a central server, making setup easier and cheaper
  • Can easily handle a game with up to 10 players
  • Easy way to share data between players
  • Server error can’t take down the entire game
  • Need to manage the loss of a ‘peer’ (due to network outage, rage quit etc) or this could break the game flow
  • Possibility for users to cheat by altering the data they’re sending

What can I make with pub/sub and p2p?

Defining the rules

  1. A host creates a game and receives a share link to invite others.
  2. Other players join the game.
  3. Once all players are in, the host starts the game.
  4. Players are each sent a ‘prompt’ card with a phrase on it.
  5. Players draw their prompt on an HTML canvas, they are given 180 seconds to do this.
  6. Players’ drawings are passed along to the person who joined after them, except for the last player, who’s drawing is passed to the host.
  7. Players then have to enter a ‘caption’ for that picture into a textbox, they are given 180 seconds to do so.
  8. Steps 6 and 7 repeat until each player has received the ‘stack’ of drawings from their original prompt.
  9. The stacks of drawings and captions are shown to each player to vote on which submission was their favourite.
  10. Votes are counted and shown to players.
  11. Host is offered a prompt to start a new game.

Defining the state from the rules

Writing the game’s user interface

Extending the game

Sharing the lols



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store