Chapter 11. Find the Buried Treasure!

Let’s put what we’ve learned so far to good use and make a game! The aim of this game is to find the hidden treasure. In this game, the web page will display a treasure map. Inside that map, the program will pick a single pixel location, which represents where the hidden treasure is buried. Every time the player clicks the map, the web page will tell them how close to the treasure they are. When they click the location of the treasure (or very close to it), the game congratulates them on finding the treasure and says how many clicks it took to find it. Figure 11-1 shows what the game will look like after a player clicks the map.

Figure 11-1. The buried treasure game

Designing the Game

Before we start writing ...

Get JavaScript for Kids now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.