Pygame challenges
Each challenge hands you a broken game and one function to write; fix them all and the whole game is your code.
Catch
Beginner. Move a basket, make fruit fall faster and faster, catch it, then add lives and levels: four functions make Catch.
- 1. Move the basketThe basket is stuck: the arrow keys do nothing.10 XP
- 2. Fruit falls fasterThe fruit drifts down at one slow, steady pace, like a feather.15 XP
- 3. Catch the fruitThe fruit falls straight through the basket.20 XP
- 4. Lives and levelsDropping fruit costs nothing and the game never gets harder, so there is no way to lose.25 XP
Bounce
Beginner. Make a ball bounce, keep a paddle on screen and aim your shots, then play the Pong you built.
Snake
Intermediate. Move the head, detect crashes, eat and grow, and stop U-turns: four functions make Snake.
- 1. Move the snakeThe snake is frozen: its head never moves.15 XP
- 2. Crash detectionThe snake goes through walls and through itself without a scratch.20 XP
- 3. Eat and growThe snake swims over the food and stays the same length.25 XP
- 4. No U-turnsPress the arrow pointing back and the snake bites itself at once.20 XP
Platformer
Intermediate. Jump only from the ground, land on platforms, pick up coins and make the camera follow you through a level four screens wide.
- 1. Jump from the groundPress jump in mid-air and the runner jumps again, so you can fly over everything.20 XP
- 2. Land on platformsThe runner drops straight through every platform, the ground too.30 XP
- 3. Collect the coinsRun through a coin and nothing happens: it stays there and the count stays at 0.30 XP
- 4. Follow the runnerRun to the right and the runner leaves the screen: the view never moves.35 XP
Alien Wave
Intermediate. Cool the cannon, clear away spent bullets, march the wave and score the hits, then hold off wave after wave in the shooter you built.
- 1. Cool down the cannonHold Space and the cannon fires a solid beam, a new bullet every single frame.15 XP
- 2. Clear away spent bulletsAfter three shots the cannon goes quiet: bullets that flew off the top are still in the list.20 XP
- 3. March the waveThe wave marches off the side of the screen and never comes back.30 XP
- 4. Shoot down the aliensBullets fly straight through the aliens.40 XP
Blocks
Advanced. Turn pieces, check that they fit and clear full rows to build a falling-blocks puzzle.
Maze Chase
Advanced. Keep out of the walls, open the side tunnels, eat the dots and teach a ghost the shortest way to you, then survive the chase you built.
- 1. Stay out of the wallsThe player walks straight through the walls and off the edge of the screen.15 XP
- 2. Tunnels at the edgesThe tunnels at the sides of the maze are dead ends.20 XP
- 3. Eat the dotsThe player runs over the dots, but they never disappear and the score stays at 0.25 XP
- 4. The ghost hunts youThe red ghost only heads straight for you, so any wall between you leaves it stuck.40 XP
New to pygame? The pygame fundamentals cover the game loop, drawing, keys and collisions first. Progress is kept in this browser.