Scoreboard
Weâll want to keep score in this game so, in the code outline at the top of our code, add a call to the addScoreboard() function.
â | âvarâ ground = addGround(); |
â | âvarâ water = addWater(); |
» | âvarâ scoreboard = addScoreboard(); |
But thereâs no addScoreboard() function yet, so this temporarily breaks things. To quickly get everything back, add the function after the last curly brace in the addRiver() function.
â | âfunctionâ addScoreboard() { |
â | âvarâ scoreboard = ânewâ Scoreboard(); |
â | scoreboard.score(0); |
â | scoreboard.timer(); |
â | scoreboard.help( |
â | â'left / right arrow keys to turn. 'â + |
â | â'space bar to move forward. 'â + |
â | â'R to restart.'â |
â | ); |
â | âreturnâ scoreboard; ... |
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.