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 Gioca con un amico Opzione 1


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.

Scegli un’estensione
Tifo al traguardo
Programma un suono da riprodurre se il giocatore raggiunge la linea del traguardo.
Gioca con un amico Opzione 1
Aggiungi un secondo giocatore.
Gioca con un amico Opzione 2
Sfida un amico facendogli controllare i nemici.
Il traguardo che si restringe
Programma il traguardo a restringersi se il giocatore totalizza più punti.
Punti bonus!
Crea uno sprite che, se toccato, regala al giocatore punti extra.
Cambia il design del livello
Programma lo sfondo a cambiare ogni volta che il giocatore totalizza 5 punti.
arrow_backward Indietro
Avanti arrow_forward
  1. Fai clic su qualsiasi casella per andare sul video dei componenti aggiuntivi.
  2. Quando hai terminato, torna sulla schermata dei componenti aggiuntivi e prova un altro componente aggiuntivo!