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.

Scegli un’estensione
Riproduci suono se preso
Aggiungi un suono al tuo gioco e programma il progetto a riprodurre quel suono.
Gioca con un amico
Programma uno sprite affinché sia controllato da un altro sprite.
Cambia il giocatore
Cambia il costume del giocatore quando tocca un altro sprite.
Accelera la caccia
Rendi più difficile il gioco velocizzando l'inseguimento.
Punteggio alto!
Crea una nuova variabile che memorizzi l'attuale punteggio più alto.
arrow_backward Indietro
Avanti arrow_forward
Istruzioni
  1. Fai clic su qualsiasi casella per andare al video sui componenti aggiuntivi.
  2. Quando hai terminato, torna sulla schermata dei componenti aggiuntivi e prova un altro componente aggiuntivo!