Program Arcade Games

With Python And Pygame

There are many example programs available for download at:

http://ProgramArcadeGames.com/python_examples/en/python_examples.zip

Here is a brief description of what is available:

Example programs that don't involve graphics:

Program that calculates miles-per-gallon.

calculate_miles_per_gallon.py

calculate_miles_per_gallon.py Calculates the kinetic energy of an object.

calculate_kinetic_energy.py

calculate_kinetic_energy.py Simple example if statements.

if_statement_examples.py

statements. if_statement_examples.py Simple example for loops.

for_loop_examples.py

loops. for_loop_examples.py Simple example while loops. (Chapter 4

while_loop_examples.py

loops. (Chapter 4 while_loop_examples.py Simple example for encrypting text.

simple_encryption.py

simple_encryption.py Simple example for decrypting text.

simple_decryption.py

simple_decryption.py Binary and linear searches.

searching_example.py

searching_example.py Property check examples.

property_check_examples.py

Programs that show how to use graphics:

This opens up a blank pygame window. It is a good template to use when starting a new program.

pygame_base_template.py

pygame_base_template.py This file demonstrates setting up a window and drawing rectangles, polygons, text, and other basic shapes.

simple_graphics_demo.py

simple_graphics_demo.py See how to rotate text.

text_rotate.py

text_rotate.py Demos all the commands in the draw module.

draw_module_example.py

draw_module_example.py Animate a bouncing rectangle around the screen.

bouncing_rectangle.py

bouncing_rectangle.py Animate a several bouncing balls.

bouncing_balls.py

bouncing_balls.py This shows how to use an array to animate and track multiple objects. In this case, snow flakes.

animating_snow.py

animating_snow.py This file draws a snowman inside of a function. The program can then call the draw snowman function and draw several snowmen easily.

functions_and_graphics.py

functions_and_graphics.py Move an object with the mouse.

move_mouse.py

move_mouse.py Move an object with the keyboard.

move_keyboard.py

move_keyboard.py Move an object with the game controller.

move_game_controller.py

move_game_controller.py Show how to read everything off a gamepad/controller/joystick.

joystick_calls.py

joystick_calls.py Display bitmapped images (png, jpg) to a screen. Make sounds.

bitmapped_graphics.py

bitmapped_graphics.py Display a board based on a two-dimensional grid. Useful when creating games like tic-tac-toe, minesweeper, memory-match, connect-four, etc.

array_backed_grid.py

array_backed_grid.py Display one or more pages of instruction before the game starts.

instruction_screen.py

instruction_screen.py 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.

background_music.py

background_music.py Shows how to display a centered "Game Over" message, and stop game play when a game is over.

game_over.py

game_over.py Display a line sweeping around in a circle like a radar.

radar_sweep.py

radar_sweep.py Count up and count down timers.

timer.py

timer.py Using recursion to make nested rectangles.

recursive_rectangles.py

recursive_rectangles.py Using recursion to make fractals.

fractal.py

fractal.py Put a timer on the screen.

timer.py

How to use sprites:

Move a sprite with the mouse and collect blocks.

sprite_collect_blocks.py

sprite_collect_blocks.py Same as collect blocks example, but all the sprites move.

moving_sprites.py

moving_sprites.py Same as collect blocks example, but you can move the sprite by clicking to pick them up.

pick_up_blocks.py

pick_up_blocks.py Rather than just move down, these sprites bounce.

moving_sprites_bounce.py

moving_sprites_bounce.py Prior example too boring? Get the sprites to move in circles.

sprite_circle_movement.py

sprite_circle_movement.py Expands the prior example to show how to manage a game with levels. Level advances when all the blocks are cleared.

sprite_collect_blocks_levels.py

sprite_collect_blocks_levels.py Same as sprite_collect_blocks.py but with a black circle instead of a block.

sprite_collect_circle.py

sprite_collect_circle.py Same as sprite_collect_blocks.py but with a graphic instead of a block.

sprite_collect_graphic.py

sprite_collect_graphic.py Same as sprite_collect_blocks.py but with a graphic instead of a block.

sprite_rotating.py

sprite_rotating.py Same idea as sprite_collect_blocks.py but uses a Game class to organize the code. This is a more advanced way of organizing the code. It helps if you want to “restart” a game once it is over.

game_class_example.py

class to organize the code. This is a more advanced way of organizing the code. It helps if you want to “restart” a game once it is over. game_class_example.py Move a sprite around the screen with the mouse.

move_sprite_mouse.py

move_sprite_mouse.py Move a sprite with the keyboard in discrete “jumps.”

move_sprite_keyboard_jump.py

move_sprite_keyboard_jump.py Move a sprite with the keyboard smoothly and continuously while a key is pressed.

move_sprite_keyboard_smooth.py

move_sprite_keyboard_smooth.py Move a sprite with a game controller or joystick.

move_sprite_game_controller.py

move_sprite_game_controller.py Basic Pong game using two game controllers.

pong.py

pong.py How to manage bullets with sprites.

bullets.py

bullets.py How to aim bullets.

bullets_aimed.py

bullets_aimed.py Control a snake as it moves around the screen.

snake.py

Progressively more complex examples for a platformer game:

Move a sprite around the screen, but not let it move through walls.

move_with_walls_example.py

move_with_walls_example.py More complex version of prior example, with multi-colored walls, and multiple rooms.

maze_runner.py

maze_runner.py Get the player to jump off platforms.

platform_jumper.py

platform_jumper.py Like platform jumper, but scroll side to side.

platform_scroller.py

platform_scroller.py Make those platforms move!

platform_moving.py

platform_moving.py A multi-file example that shows a platformer using sprite sheets.

Sprite Sheets

Also some longer example programs are included.

You are not logged in. Log in here and track your progress.﻿