Program Arcade GamesWith Python And Pygame
Download all these examples along with supporting files in a zip file:
Program that calculates miles-per-gallon. (
Calculates the kinetic energy of an object. (
Simple example for encrypting text. (
Simple example for decrypting text. (
This opens up a blank pygame window. It is a good template to use when starting a new program. (
This file demonstrates setting up a window and drawing rectangles, polygons, text, and other basic shapes. (
Demos all the commands in the draw module.
Animate a bouncing rectangle around the screen. (
This shows how to use an array to animate and track multiple objects. In this case, snow flakes. (
This file draws a snowman inside of a function. The program can then call the draw snowman function and draw several snowmen easily. (
Move an object with the game controller (
Show how to read everything off a gamepad/controller/joystick. (
Display bitmapped images (png, jpg) to a screen. Make sounds. (
Display a board based on a two-dimensional grid. Useful when creating games like tic-tac-toe, minesweeper, memory-match, connect-four, etc. (
Display one or more pages of instruction before the game starts.
Plays background music. When the music is over, an event is triggered and a different song starts. The music is included in the downloadable zip file, or you can follow the links in the comments to download the music.
Shows how to display a centered "Game Over" message, and stop game play when a game is over.
Display a line sweeping around in a circle like a radar.
Using recusion to make nested rectangles. (
Using Trigonometry (off-site link) - If you want things that bounce, wave, or even pointing cannons, then follow this link to Al Sweigart's page and read up on using trigonometry with your code.
Move a sprite with the mouse and collect blocks. (
Same as collect blocks example, but all the sprites move. (
Expands the prior example to show how to manage a game with levels. Level advances when all the blocks are cleared.
Same as sprite_collect_blocks.py but with a black circle instead of a block. (
Same as sprite_collect_blocks.py but with a graphic instead of a block. (
Move a sprite around the screen with the mouse. (
Move a sprite with the keyboard in discrete 'jumps'. (
Move a sprite with the keyboard smoothly and continously while a key is pressed. (
Move a sprite with a game controller or joystick. (
Basic Pong game using two game controlers.
Make a cat animate walking. How to animate a sprite using several images. (You'll need to download the zip file to get the cat images.)
How to manage bullets with sprites.
Move a sprite around the screen, but not let it move through walls.
More complex version of prior example, with multi-colored walls, and multiple rooms.
Get the player to jump off platforms.
Like platform jumper, but scroll side to side.
Control a snake as it moves around the screen.
Python Pygame Installer Tutorial- Create an installer for your Python program. Allow other people to play your game too!
example_sorted_names.txt - Sample file of names used in searching_example.py
searching_example.py - Example linear and binary searches
AliceInWonderLand.txt - Text of Alice In Wonderland. Source: Project Gutenberg
sorting_examples.py - Example code for the insertion and selection sorts.
high_score.py - Example that shows how to read and write a high score to the disk so that it persists between program runs.
Pygame Website - The main website for Pygame
Pygame Documentation - Documentation on the commands availabe for Pygame
You are not logged in. Log in
here and track your progress.