Программирование аркадных игр
и обучение информатикеExample code and programs
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:
1.1 Text examples
Example programs that don't involve graphics:
- Program that calculates miles-per-gallon.
calculate_miles_per_gallon.py - Calculates the kinetic energy of an object.
calculate_kinetic_energy.py - Simple example if statements.
if_statement_examples.py - Simple example for loops.
for_loop_examples.py - Simple example while loops. (Chapter 4
while_loop_examples.py - Simple example for encrypting text.
simple_encryption.py - Simple example for decrypting text.
simple_decryption.py - Binary and linear searches.
searching_example.py - Property check examples.
property_check_examples.py
1.2 Graphics examples
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 - This file demonstrates setting up a window and drawing rectangles, polygons, text, and other basic shapes.
simple_graphics_demo.py - See how to rotate text.
text_rotate.py - Demos all the commands in the draw module.
draw_module_example.py - Animate a bouncing rectangle around the screen.
bouncing_rectangle.py - Animate a several bouncing balls.
bouncing_balls.py - This shows how to use an array to animate and track multiple objects. In this case, snow flakes.
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 - Move an object with the mouse.
move_mouse.py - Move an object with the keyboard.
move_keyboard.py - Move an object with the game controller.
move_game_controller.py - Show how to read everything off a gamepad/controller/joystick.
joystick_calls.py - Display bitmapped images (png, jpg) to a screen. Make sounds.
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 - Display one or more pages of instruction before the game starts.
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 - Shows how to display a centered "Game Over" message, and stop game play when a game is over.
game_over.py - Display a line sweeping around in a circle like a radar.
radar_sweep.py - Count up and count down timers.
timer.py - Using recursion to make nested rectangles.
recursive_rectangles.py - Using recursion to make fractals.
fractal.py - Put a timer on the screen.
timer.py
1.3 Sprite examples
- Move a sprite with the mouse and collect blocks.
sprite_collect_blocks.py - Same as collect blocks example, but all the sprites move.
moving_sprites.py - Same as collect blocks example, but you can move the sprite by clicking to pick them up.
pick_up_blocks.py - Rather than just move down, these sprites bounce.
moving_sprites_bounce.py - Prior example too boring? Get the sprites to move in circles.
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 - Same as sprite_collect_blocks.py but with a black circle instead of a block.
sprite_collect_circle.py - Same as sprite_collect_blocks.py but with a graphic instead of a block.
sprite_collect_graphic.py - Same as sprite_collect_blocks.py but with a graphic instead of a block.
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 - Move a sprite around the screen with the mouse.
move_sprite_mouse.py - Move a sprite with the keyboard in discrete “jumps.”
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 a sprite with a game controller or joystick.
move_sprite_game_controller.py - Basic Pong game using two game controllers.
pong.py - How to manage bullets with sprites.
bullets.py - How to aim bullets.
bullets_aimed.py - Control a snake as it moves around the screen.
snake.py
1.4 Platformer examples
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 - More complex version of prior example, with multi-colored walls, and multiple rooms.
maze_runner.py - Get the player to jump off platforms.
platform_jumper.py - Like platform jumper, but scroll side to side.
platform_scroller.py - Make those platforms move!
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.
Copyright © 2017
English version by Paul Vincent Craven
Spanish version by Antonio Rodríguez Verdugo
Russian version by Vladimir Slav
Turkish version by Güray Yildirim
Portuguese version by Armando Marques Sobrinho and Tati Carvalho
Dutch version by Frank Waegeman
Hungarian version by Nagy Attila
Finnish version by Jouko Järvenpää
French version by Franco Rossi
Korean version by Kim Zeung-Il
Chinese version by Kai Lin
English version by Paul Vincent Craven
Spanish version by Antonio Rodríguez Verdugo
Russian version by Vladimir Slav
Turkish version by Güray Yildirim
Portuguese version by Armando Marques Sobrinho and Tati Carvalho
Dutch version by Frank Waegeman
Hungarian version by Nagy Attila
Finnish version by Jouko Järvenpää
French version by Franco Rossi
Korean version by Kim Zeung-Il
Chinese version by Kai Lin