July 2018
Beginner to intermediate
374 pages
8h 54m
English
To complete the code outline, we next add the scoreboard. Put this below the addAvatar() function and above the reset() function.
| | function addScoreboard() { |
| | var scoreboard = new Scoreboard(); |
| | scoreboard.score(); |
| | scoreboard.help( |
| | "Use arrow keys to move and the space bar to jump. " + |
| | "Don't let the fruit get past you!!!" |
| | ); |
| | return scoreboard; |
| | } |
This is similar to the scoreboard we used in Chapter 11, Project: Fruit Hunt, so the code should look familiar. Uncomment the addScoreboard function in the code outline.
| | var ground = addGround(); |
| | var avatar = addAvatar(); |
| » | var scoreboard = addScoreboard(); |
| | |
| | reset(); |
You should now see a scoreboard showing 0 points.
Read now
Unlock full access