July 2018
Beginner to intermediate
374 pages
8h 54m
English
Happily, the Scoreboard code that we use is an object, which makes our job of adding two scoreboards easier—yay! The code that adds the one scoreboard should be below where we create launcher1 and launcher2. It should look something like the following:
| | 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!"); |
| | } |
This code creates one scoreboard for the entire game. ...
Read now
Unlock full access