July 2018
Beginner to intermediate
374 pages
8h 54m
English
The rest of the code in this chapter will go in the usual place, below the START CODING ON THE NEXT LINE line. More specifically, add the following scoreboard code after the avatar and marker code, but above the makeTreeAt() function.
| | var scoreboard = new Scoreboard(); |
| | scoreboard.countdown(45); |
| | scoreboard.score(); |
| | scoreboard.help( |
| | 'Arrow keys to move. ' + |
| | 'Space bar to jump for fruit. ' + |
| | 'Watch for shaking trees with fruit. ' + |
| | 'Get near the tree and jump before the fruit is gone!' |
| | ); |
This creates a new scoreboard. It tells the scoreboard to start a countdown timer, show the score, and add a help message. That should add a nifty-looking scoreboard to our screen, complete with the time remaining ...
Read now
Unlock full access