Guess the Number Game

Because this is a book on writing games in HTML5 for Facebook, let's walk through an example that implements a simple game, reinforcing the techniques in this chapter. For this example, we build a High–Low game, where the computer chooses a random number and you try to guess what it is.

The first thing we need to do is to define the rules of the game, and the expectations. As this is just meant to show off some of the code I have discussed in this chapter, the first iteration of this game is pretty bare bones. However, there is a second iteration of the code base with a few more bells and whistles (e.g., interface enhancements) that make the game look a bit nicer in the source code for this book.

For this game of High–Low, ...

Get Beginning Facebook Game Apps 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.