Planning a Simple Social Game

The best way to understand how to create an HTTP-based multiplayer game is to build one. You could build lots of complicated social games, but building a simple game that serves as an example of how the various pieces of a multiplayer game connect should be enough to get you started on something more involved.

The game that you build is a simple game based on Ian Bogost’s social game parody Cow Clicker. The point of Cow Clicker is, as you may have guessed, to click your cow at regular intervals and get points for doing so. The game built in this chapter builds a similar game but with an exciting twist: You click a blob instead of a cow. The blob in question is the enemy blob from the platformer game built in Chapter 18, “Creating a 2-D Platformer.”

Although the game is quite simple, it requires all the pieces of a typical HTTP-based multiplayer game: a server to run the game, an authentication system to log in users, a database to store the user’s progress, and game logic that resides on the server to control the actions a player can take.

The server used is a simple Node.js application running the Express framework. Being a social game, it uses Facebook as an authentication system to allow users to log in without entering their e-mail address or creating a password. To store progress, the game connects to a NoSQL database named MongoDB. The server will be set up to allow only the players to click on their blob at some specified interval to prevent ...

Get Professional HTML5 Mobile Game Development now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.