Skip to content

Please update your browser

Your browser version is not supported by this site. CS First may not work properly. Learn more

arrow_back Keeping Score

Choose an Add-On
play_circle_filled
Start Screen
Add a starting screen with instructions for your game.
arrow_forward
play_circle_filled
Keeping Score
Keep track of how long a racer stays alive and display the score.
arrow_forward
play_circle_filled
Cheer On
Create a sprite that cheers on the racer.
arrow_forward
play_circle_filled
Extreme Tricks
Program your racer to do a cool trick at the press of a button.
arrow_forward
play_circle_filled
Power Ups
Create a power up that shrinks the racer.
arrow_forward
play_circle_filled
Crash Sound
Add a sound that plays when the racer crashes into an obstacle.
arrow_forward
  • 1. Quick Survey
  • 2. Introduction to Loops
  • 3. Control the Racer
  • 4. Moving Obstacles
  • 5. Clone More Obstacles
  • 6. Program the Losing Condition
  • 7. Add-Ons
  • 8. Reflection
  • 9. Wrap-up: Extreme Sports
  • 10. Wrap-up: Share Your Project
  • 11. Wrap-up: Show Your Project
arrow_backward Back Next arrow_forward
Transcript

In this add-on, you will keep track of how long the racer stays alive on the obstacle course, and display the score at the end. Open the “sensing” menu, and find the “timer” block. Click the checkbox next to this block to display the timer on the stage.

The timer counts the number of seconds since the flag was clicked. To see how this works, click the flag. Notice that the timer gets reset to zero every time the flag is clicked.

Now, you’ll make the sprite say the timer’s value when the racer hits an obstacle.

Select the racer sprite, and add the “timer” block to your project. From the “looks” menu, add a “say” block to your losing condition “if” statement. Then, place the “timer” block inside the “say” block.

Test out your code by clicking the flag. Great! The sprite says the timer’s value when the game ends. But, the score keeps changing if you hit more obstacles after the game.

To freeze the score, open the “control” menu, and add a “stop” block to the end of the “if” statement. Open the dropdown menu on that block, and select “this script.”

Test your code again. Great! It works!

However, your user might get confused because it’s not clear what this number means. Open the operators menu, and place a “join” block in the “say” block. This block joins two phrases together. In this example, the join block will say “Your score is “ in the first half, and “timer” in the second half. Test it out. Now the racer says “Your score is “ and the score. This makes it much clearer to the user what this number means! Make your block say whatever you want. Here’s the game plan: Make the racer announce the player’s score using a “timer” block, a “say” block, a “stop” block, and a “join” block.

Instructions
  1. Choose an add-on, and click "Watch" to learn how to customize your project.
  2. When you finish, come back to the add-ons screen and try another add-on!