Welcome Installation Getting Started User Interaction Build a Game #1 Build a Game #2 Build a Game #3 Colours Coordinates API Reference Globals Window Camera Mouse Key Rect Image Text Shape Line Screen Sound Base

Build a Game #1

It's time to build our first game: Coin Collector. You control a player with the arrow keys, and try to collect the coins before the enemy does.

The Player

We'll draw the protagonist by loading the MAN image.


    

Use if statements to detect which keys are being pressed and move the man in that direction by 2 pixels. Feel free to lean more about coordinates.


    

The Coin

Draw the coin by loading the COIN image.


    

We want the coin to start in a random position. To do this, use the random function to generate random x and y positions for the coin.


    

We can collect the coin by checking if the player collides with the coin, and then moving it to another random position.


    

Sound Effects

To add audio, use the Sound class to load sound effects. Then use sound.play to play the sound.

sound = Sound(BLIP)
sound.play()

Now load the PICKUP sound effect and play it whenever the player collects a coin.


    

Follow the next lesson to add an enemy and display a score.

User Interaction Build a Game #2