CHAPTER 11

image

Multiplayer with WebSockets

No matter how challenging we make a single-player game, it will always lack the challenge of competing against another human being. Multiplayer games allow players to either compete against each other or work cooperatively toward a common goal.

Now that we have a working single-player campaign, we will look at how we can add multiplayer support to our RTS game by using the HTML5 WebSocket API.

Before we start adding multiplayer to our game, let’s first take a look at some networking basics using the WebSocket API with Node.js.

Using the WebSocket API with Node.js

The heart of our multiplayer game is the ...

Get Pro HTML5 Games 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.