In this game, the computer controls the enemies. But, in this screencast, you’ll programthe enemies so they can be controlled by a second player. You should only complete thisscreencast 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 newclone 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 aplayer presses keys. Often, in two-player games when player 1 usesthe 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 sharkshould 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 similarcode 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.
Program the finish line to get smaller as the player scores more 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.