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 Das Spiel mit einem Freund spielen

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!

Erweiterung auswählen
Einen Klangeffekt einbauen
Einen Klang zu eurem Spiel hinzufügen und ihn in eurem Projekt abspielen.
Das Spiel mit einem Freund spielen
Eine Figur hinzufügen, die von einem zweiten Spieler gesteuert werden kann.
Die Spielfigur umziehen
Das Kostüm eurer Spielfigur ändern, wenn sie eine andere Figur berührt.
Die Verfolgung beschleunigen
Den Schwierigkeitsgrad erhöhen, indem ihr die Verfolgung beschleunigt.
Eine Variable „Highscore“ hinzufügen.
Eine neue Variable erstellen, die die aktuelle höchste Punktzahl des Spiels speichert.
arrow_backward Zurück
Weiter arrow_forward
Anweisungen
  1. Klickt auf eines der Kästchen, um zum Video mit den Erweiterungen zu gelangen.
  2. Kommt danach zur Seite mit den Erweiterungen zurück und probiert eine andere Erweiterung aus!