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 2


In this game, the computer controls the enemies. But, in this screencast, you’ll program the enemies so they can be controlled by a second player. You should only complete this screencast if you haven’t already programmed the other 2-player option.

You have already completed some of the programming for the sharks. Right now, every time a new clone appears they point in a random direction, then keep moving in whichever direction.

If a shark hits the edge of the screen, it bounces, then keeps moving forward again.

You still want the sharks to act like that, but now you also want them to move when a player presses keys. Often, in two-player games when player 1 uses the arrow keys, player 2 uses the leters W, A, S, and D, with “w” meaning “up,” “a” meaning “left,” “s” meaning “down,” and “d” meaning “right.”

Try programming a single key first, like the “a” key.

First, click on the shark sprite.

Then, select a “when key is pressed” event and change the value to “a.”

When the 'a' key is pressed, the sharks should turn left. So, select a “turn” block from the motion menu.

Before going any further, test your code to make sure it works.

When you press the green flag, the first shark should bounce around the screen, just like it did originally. But, when you press the “a” key, it should turn left. It does! Great.

Now that you created code for turning left and you know that it works, you can use similar code to make the shark turn right.

You can duplicate your block stack to make it easier.

Change the "turn" block to a right turn.

Then, change the key to “d.”

Now, it’s time to test the code again.

Perfect! The shark moves, and when you press “a” it turns left. Press “d,” and it turns right.

As the game progresses, player 2 builds a larger swarm of sharks, and all additional clones are also controlled by the “a” and “d” keys.


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!