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

Transcript

In this add-on, you'll enable a second player to control the enemies.

Complete this video only if you haven't already programmed the other two-player option.

To start, program the enemies to move when a player presses keys.

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

Program the enemy sprites to move to the left when the A key is pressed.

Select a when key pressed event and change the value to A.

When the key is pressed, enemy sprites should turn left, so, select a turn block from the motion menu.

Test your code.

When you click the flag, the first enemy sprite bounces around the screen, just like it did originally.

But when you press the A key, it turns left.

Great.

Now that you created code for turning left, use similar code to make the enemy sprite turn right.

Change the turn to a right turn.

Then, change the key press event to the D key.

Click the flag to test.

The enemy sprite moves, and when you press A it turns left.

Press D, and it turns right.

As the game progresses, and player two builds a larger swarm of enemy sprites, all of the new clones are also controlled by the A and D keys.

Great.

Now it's your turn.

Add events that allow a second player to control the enemy sprite using the A and D keys.

Use the turn blocks to turn the enemies right and left.

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.
arrow_backward Back
Next arrow_forward
Instructions
  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!
Attributions
  • The song “Magic Marker” is © YouTube-- CC-BY-SA 4.0 does not apply.