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.