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 Play with a Friend option 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.


Choose an Add-On
Finish Line Cheer
Program a sound to play if the player touches the finish line.
Play with a Friend Option 1
Add a second player to the game.
Play with a Friend option 2
Challenge a friend by having them control the enemies.
Shrinking Finish-Line
Program the finish line to get smaller as the player scores more points.
Bonus Points!
Create a sprite that, when touched, gives the player extra points.
Changing Level Design
Program the backdrop to change every time the player scores 5 points.
arrow_backward Back
Next arrow_forward
  1. Choose an Add-On, and click "watch" to learn how to build it.
  2. Once you finish one Add-On, try another one below the video!