July 2018
Beginner to intermediate
374 pages
8h 54m
English
We’ll want to keep score in this mini-game, so let’s add a scoreboard. Below the line that creates the new Launcher(), add the usual scoreboard code:
| | var scoreboard = new Scoreboard(); |
| | scoreboard.countdown(60); |
| | scoreboard.score(0); |
| | scoreboard.help( |
| | 'Use right and left arrow keys to point the launcher. ' + |
| | 'Press and hold the down arrow key to power up the launcher. ' + |
| | 'Let go of the down arrow key to launch. ' + |
| | 'Watch out for the wind!!!' |
| | ); |
| | scoreboard.onTimeExpired(timeExpired); |
| | function timeExpired() { |
| | scoreboard.message("Game Over!"); |
| | } |
You can skip the help text for now if you’re eager to get back to coding. Just don’t forget to add it later—it’s no fun playing a game where you don’t know the ...
Read now
Unlock full access