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 1


A game that’s fun for one person can be even more fun for 2! In this screencast, you’ll create a second player sprite that will be controlled using the W, A, S, and D keys on the keyboard. You should only complete this screencast if you haven’t already programmed the other 2-player option. The player 2 sprite will have a lot of the same code as the first player sprite you programmed, so copy the player 1 sprite by right clicking it and selecting “duplicate.”

It will be hard to tell which player is which if both players look the same.

To change player 2’s appearance, click on the costumes tab, then “choose new costume from library.” Pick a costume and click ok.

You may want to click the x to delete the other costume, because you won’t need it for this project. Right now, player 2 is programmed to turn when the arrow keys are pressed, just like player 1. That won’t work – two players can’t control 2 different sprites using the same keys.

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

First click on the scripts tab, and change the left arrow key to “a” and the right arrow key to “d.”

Test your code.

Did that work? Great! Now the two sprites are being controlled by different keys.

The "go to" block at the end of the space key block stack tells the sprite where to start.

In this case, the sprite starts at -222 and 3.

You should make your sprite start somewhere different.

Change the y-value in your "go to" block to something different.

In this project, the sprite will have a value of -100, but you can make it whatever you want!

Ok! That looks much better. Wait! both players only have 1 score!

To give player 2 a different score, you’ll need to make a new variable to store player 2’s score. You can call this one “player2 score.”

Now, when player 2’s sprite crosses the finish line, you need to make sure player 2’s score goes up, instead of player 1’s.

To do that, click the drop down menu next to “change score by,” and select “player2 score”.

Then, start player 2’s score at 0 by clicking the drop down menu at “set score to 0” and selecting “player 2 score.”

What happens when you test it now?

Good! Both players can score points now.

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!