Game Development Reference
In-Depth Information
Adding a second player
Driving around the circuit on your own is fun but not very challenging. It would be much
beter if you could invite a friend to compete against. In this step, we will introduce a second
player character. Both characters will be visible on the same screen and will be controlled
with one keyboard. We're efecively building a simple form of muliplayer.
Engage thrusters
To create a second player, we mainly have to copy the work we've done already. We need a
second control sprite and a second kart sprite. We already added a Mario sprite to the game,
so let's bring in his brother Luigi as the second player:
1.
Right-click on the control sprite named player1 and choose duplicate .
2.
The copy will be called player2 automaically. If that's not the case,
change the name manually.
3.
Go to the player2 Scripts tab.
4.
Change the key pressed controls from a and d to left arrow and right arrow
respecively.
The other script works exactly the same as for the player1 sprite.
Copying the sprite can cause some trouble with the variables. So let's make a new
speed variable to be used for the second player sprite. We will name this speed2 .
We also need another kart costume set. Instead of a guy in red, let's make the second
player a guy in green:
 
Search WWH ::




Custom Search