July 2018
Beginner to intermediate
374 pages
8h 54m
English
Eventually the raft reaches the finish line. And then it falls off the edge of the river and keeps right on going. And going. Instead, let’s pause the game so players can take a moment to admire their score before trying again. We need to make changes in four places: in our code outline and in the reset, animate, and gameStep functions.
Let’s start with the code outline. Before the call to the reset function, we need to add a line for the gameOver variable.
| » | var gameOver; |
| | var ground = addGround(); |
| | var water = addWater(); |
| | var scoreboard = addScoreboard(); |
| | var raft = addRaft(); |
| | reset(); |
Other functions will use that variable to decide whether they need to animate or update the game. JavaScript is pretty uptight ...
Read now
Unlock full access