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 Mit einem Freund spielen – Option 1

Transcript

A game that’s fun for one person can be even more fun for 2! In this screencast, you’ll create a second player sprite that will be controlled using the W, A, S, and D keys on the keyboard. You should only complete this screencast if you haven’t already programmed the other 2-player option. The player 2 sprite will have a lot of the same code as the first player sprite you programmed, so copy the player 1 sprite by right clicking it and selecting “duplicate.”

It will be hard to tell which player is which if both players look the same.

To change player 2’s appearance, click on the costumes tab, then “choose new costume from library.” Pick a costume and click ok.

You may want to click the x to delete the other costume, because you won’t need it for this project. Right now, player 2 is programmed to turn when the arrow keys are pressed, just like player 1. That won’t work – two players can’t control 2 different sprites using the same keys.

2-player games generally use the W, A, S, and D keys for the the second player.

First click on the scripts tab, and change the left arrow key to “a” and the right arrow key to “d.”

Test your code.

Did that work? Great! Now the two sprites are being controlled by different keys.

The "go to" block at the end of the space key block stack tells the sprite where to start.

In this case, the sprite starts at -222 and 3.

You should make your sprite start somewhere different.

Change the y-value in your "go to" block to something different.

In this project, the sprite will have a value of -100, but you can make it whatever you want!

Ok! That looks much better. Wait! both players only have 1 score!

To give player 2 a different score, you’ll need to make a new variable to store player 2’s score. You can call this one “player2 score.”

Now, when player 2’s sprite crosses the finish line, you need to make sure player 2’s score goes up, instead of player 1’s.

To do that, click the drop down menu next to “change score by,” and select “player2 score”.

Then, start player 2’s score at 0 by clicking the drop down menu at “set score to 0” and selecting “player 2 score.”

What happens when you test it now?

Good! Both players can score points now.

Erweiterung auswählen
Jubel an der Ziellinie programmieren
Einen Klang programmieren, der abgespielt wird, wenn die Spielfigur die Ziellinie berührt.
Mit einem Freund spielen – Option 1
Einen zweiten Spieler zum Spiel hinzufügen.
Mit einem Freund spielen – Option 2
Einen Freund herausfordern, indem ihr ihn die Feinde steuern lasst.
Den Schwierigkeitsgrad erhöhen
Die Ziellinie mit steigendem Punktestand des Spielers immer kürzer werden lassen.
Bonuspunkte erzielen.
Eine Figur erstellen, die Bonuspunkte einbringt, wenn die Spielfigur sie berührt.
Ein sich änderndes Bühnenbild programmieren
Das Bühnenbild so programmieren, dass es sich jedes Mal ändert, wenn der Spieler 5 Punkte erzielt.
arrow_backward Zurück
Weiter arrow_forward
Anweisungen
  1. Klickt auf eines der Kästchen, um zum Video mit den Erweiterungen zu gelangen.
  2. Wenn ihr fertig seid, kehrt zur Seite mit den Erweiterungen zurück und probiert eine andere Erweiterung aus!