O'Reilly logo

HTML5 Games Most Wanted: Build the Best HTML5 Games by Shy Shalom, Jonas Wagner, Brian Danchilla, Rob Hawkes, David Strauß, Russell Goldenberg, Mathias Paumgarten, Egor Kuryanovich, Jonathan Bergknoff, Gaëtan Renaudeau, Seb Lee-Delisle

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

images

Chapter 9

A Real-Time Multiplayer Game Using WebSockets

In this chapter, we will walk through the creation of a simple multiplayer game. We will use the HTML5 canvas to display graphics to the user, WebSockets to facilitate communication with our server, and node.js to create the server.

WebSockets are truly a boon to game development on the web. Before the advent of WebSockets, game clients had to speak to the game's server by polling with XMLHttpRequest or by using Flash. The former has many drawbacks, —particularly that it is very wasteful of bandwidth, and the latter is something that we, as HTML5 developers, should like to avoid. WebSockets, ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required