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.
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.
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.
Program a sound to play if the player touches the finish line.
Add a second player to the game.
Challenge a friend by having them control the enemies.
Program the finish line to get smaller as the player scores more points.
Create a sprite that, when touched, gives the player extra points.
Sign in to track your progress and earn badges