Starting a Scoreboard at Zero

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

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.