Scoreboard

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 ...

Get 3D Game Programming for Kids, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.