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

Right now, only one player can play this game. In this screencast, you’ll remix this game so that a second player can control a chaser using keypress events. This screencast will demonstrate how to do that, then you’ll try it on your own.

First, select a chaser as the sprite for the second player. This sprite is going to do something different from the other chasers, so you need to rename it “player2.”

To do this, click on the property arrow above the sprite. Remember, computer scientists often work together on the same project, so it’s important to program in a way that is easy for other people to read and understand.

You programmed the chaser to bounce around the screen, but now you want it to stop moving on its own and be controlled by a second player. To make that possible, you first need to remove the code that moves this sprite. Don’t delete all of it – be sure to leave in place the if statement that checks if the two sprites are touching.

Next, you need to program events to move this sprite forward, backward, left, and right when a second player presses the arrow keys.

This screencast will fast-foward through the addition of these blocks, but when you create this code, remember that you need to add four events, four “motion” blocks and, if you want the sprite to turn smoothly, add a “repeat until not pressing” block for each event.

Once you finish coding all four events, tinker with the sprite’s speed by changing the value of the “move 10 steps” block. Play around with those values until player 2 moves slowly enough to make the game fair. Don’t worry if it takes a few tries to get this right. A big part of computer science is trying new things, testing them out, then going back to tinker with the code until you’re happy with the result.

Now, it’s your turn. Once you’ve finished programming your game for a second player, ask your neighbor to join the fun!

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!