Skip to content

Please update your browser

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

Transcript

In this game, the player scores more points the longer they avoid the chasers. In this screencast, you’ll learn how to store a high score in a variable, then you’ll try the programming on your own.

To begin, select a chaser, click on the data menu, and select “make a variable”.

Computer scientists often work together on the same project, so it’s important to use names that would be easy for anyone who looks at the code on your project to understand.

This variable will hold the score, so name it something logical like, “High Score” or “Best Time.”

Now that you’ve created a place to store the high score, you need to program the computer to change it when a new high score is set. You will do this by adding an if statement.

Your if statement should read: When the player gets caught, To program this, drag another if statement into the “if touching player” block.

This should read, “if timer is greater than high score,” so click the operators menu and select a “greater than” operator.

Then, add a “timer” variable from sensing and a “high score” variable from data.

Now, you need to set the high score to equal the timer. Add a “set high score to” block, then add the timer here.

Now, when the player’s score is displayed, the computer will check if the timer is greater than the high score. If it is, the value in the timer will become the new high score.

Now, it’s your turn! Once you’ve finished programming, set your own high score, then challenge a neighbor to beat it.

Choisir une extension
Jouer un son si attrapé
Ajoute un son à ton jeu et programme ton projet pour qu'il joue ce son.
Jouer à ton jeu avec un ami
Programme un lutin qui sera contrôlé par un autre joueur.
Modifier le joueur
Change le costume de ton joueur chaque fois qu'il touche un autre lutin.
Accélérer la poursuite
Augmente la difficulté du jeu en rendant les chasseurs plus rapides.
Record !
Crée une nouvelle variable qui enregistre le record actuel du jeu.
arrow_backward Retour
Suivant arrow_forward
Instructions
  1. Clique sur l'une des fenêtres pour accéder à la vidéo de cette extension.
  2. Quand tu as fini, reviens à l'écran des extensions et essaies-en une autre !