HTML and CSS Reference
In-Depth Information
Chapter 20
Building for Online and Social
What's in This Chapter?
• Understanding HTTP-base multiplayer
• Building a simple social game with Node.js
• Integrating with Facebook
• Connecting to a NoSQL database
• Deploying your game Code Downloads for this Chapter
You can find the code downloads for this chapter at
title.cgi?isbn=9781118301326 on the Download Code tab. The code is in the Chapter 20 download and indi-
vidually named according to the names throughout the chapter.
The games built so far in this topic have been single-player experiences, but it doesn't need to be that way: With
the Internet easily accessible from any HTML5-powered device at almost any time, you can connect your game
to a central database and make it playable from within Facebook on both desktop and mobile. This chapter cre-
ates a simple game playable from within Facebook.
Understanding HTTP-Based Multiplayer
The most basic type of a multiplayer game you can build is the one in which the client does full-page or AJAX
requests to update itself. This type of game relies on the client sending information to and requesting informa-
tion from the server. If this sounds like a typical web page, you're correct. The downside is that the server has
no capability to reverse the equation and instantly notify the client when something happens. The upside is that
you can use a standard web architecture and server to build and scale your game.
Most small-scale websites share a similar architecture: server code written in a scripting language (be it PHP,
Ruby, Python, or JavaScript) that writes and reads data to and from a persistence layer, such as a database. No
information is shared between requests except a small amount of session data; instead everything is stored in the
Search WWH ::

Custom Search