How-To Example Code

Starting Templates

../_images/starting_template.png

Starting Template Using Window Class

../_images/template_platformer.png

Platformer Template

Drawing

Drawing Primitives

../_images/happy_face1.png

Happy Face

../_images/drawing_primitives1.png

Drawing Primitives

../_images/drawing_with_functions.png

Drawing with Functions

../_images/drawing_text1.png

Drawing Text

Drawing with Loops

../_images/drawing_with_loops1.png

Drawing with Loops

../_images/nested_loops_box.png

Draw a Box with Nested Loops

../_images/nested_loops_bottom_left_triangle.png

Bottom Left Triangle

Animating Drawing Primitives

../_images/bouncing_rectangle1.png

Bouncing Rectangle

../_images/shapes.png

Bouncing Shapes

../_images/radar_sweep.png

Radar Sweep

../_images/snow.png

Falling Snow

Faster Drawing with ShapeElementLists

../_images/shape_list_demo.png

ShapeElementList Explanation

../_images/lines_buffered.png

Using a Vertex Buffer Object With Lines

../_images/shape_list_demo_skylines.png

Shape List - Skylines

../_images/gradients1.png

Gradients Example

Sprites

Sprite Player Movement

../_images/sprite_collect_coins.png

Collect Coins - Mouse

../_images/sprite_collect_coins.png

Sprite Move By Keyboard

../_images/sprite_collect_coins.png

Better Move By Keyboard

../_images/sprite_collect_coins.png

Acceleration and Friction

../_images/sprite_face_left_or_right.png

Sprite: Face Left or Right

../_images/sprite_collect_coins.png

Game Controller/Joystick

../_images/sprite_move_angle.png

Move Sprites By Angle

../_images/dual_stick_shooter1.png

Dual Stick Shooter

../_images/turn_and_move.png

Turn and Move

Sprite Non-Player Movement

../_images/sprite_collect_coins_move_down.png

Collect Coins Moving Down

../_images/sprite_collect_coins_move_bouncing.png

Collect Coins that are Bouncing

../_images/sprite_bouncing_coins.png

Sprite Bouncing Coins

../_images/sprite_collect_coins_move_circle.png

Collect Coins that are Moving in a Circle

../_images/sprite_collect_rotating.png

Animated Sprites

Sprite Pathing

../_images/follow_path1.png

Sprites That Follow a Path

../_images/sprite_follow_simple.png

Sprites That Follow The Player

../_images/sprite_follow_simple_2.png

Sprites That Follow The Player 2

../_images/line_of_sight.png

Line of Sight

../_images/astar_pathfinding1.png

A-Star Path Finding

Sprite Properties

../_images/sprite_health.png

Hit Points and Health Bars

../_images/sprite_properties.png

Sprite Properties

../_images/sprite_change_coins.png

Change coins

Games with Levels

../_images/sprite_collect_coins_diff_levels.gif

Different Levels of Clearing Coins

../_images/sprite_rooms.png

Moving Between Different Rooms

Shooting with Sprites

../_images/sprite_bullets.png

Shoot Bullets Upwards

../_images/sprite_bullets_aimed.png

Aim and Shoot Bullets

../_images/sprite_bullets_periodic.png

Have Enemies Periodically Shoot

../_images/sprite_bullets_random.png

Have Enemies Randomly Shoot

../_images/sprite_bullets_enemy_aims.png

Have Enemies Aim at Player

../_images/sprite_explosion_bitmapped.png

Sprite Explosions Bitmapped

../_images/sprite_explosion_particles.png

Sprite Explosions Particles

Sound

../_images/sound_demo.png

Sound Demo

../_images/music_control_demo.png

Music Control Demo

Camera Use

../_images/sprite_move_scrolling.png

Move with a Scrolling Screen - Centered

../_images/sprite_move_scrolling_box.png

Move with a Scrolling Screen - Margins

../_images/sprite_move_scrolling.png

Camera Shake

Platformers

Basic Platformers

../_images/sprite_move_walls.png

Move with Walls

../_images/sprite_no_coins_on_walls.png

Randomly Place Coins, But Away From Walls And Other Coins

../_images/sprite_move_animation.gif

Move with a Sprite Animation

../_images/sprite_moving_platforms.png

Moving Platforms

../_images/sprite_enemies_in_platformer.png

Platformer With Enemies

../_images/11_animate_character.png

Simple Platformer

Using Tiled Map Editor to Create Maps

../_images/sprite_tiled_map.png

Work with loading in a Tiled map file

../_images/sprite_tiled_map_with_levels.png

Work with levels and a tiled map

Procedural Generation

../_images/maze_recursive.png

Creating a Recursive Maze

../_images/maze_depth_first.png

Creating a Depth First Maze

../_images/procedural_caves_cellular.png

Procedural Caves - Cellular Automata

../_images/procedural_caves_bsp.png

Procedural Caves - Binary Space Partitioning

View Management

Instruction Screens and Game Over Screens

../_images/view_screens_minimal.png

Minimal Views Example

../_images/view_instructions_and_game_over.png

Using Views for Instruction and Game Over Screens

../_images/view_pause_screen.png

Using Views for a Pause Screen

../_images/view_screens_minimal.png

Fade In/Out of Views

Resizable Window and Fullscreen Games

../_images/resizable_window.png

Resizable Window

../_images/full_screen_example1.png

Full Screen Example

Graphical User Interface

../_images/gui_flat_button1.png

Flat Text Buttons

../_images/gui_widgets1.png

GUI Widgets

../_images/gui_ok_messagebox1.png

OK Message Box

../_images/gui_scrollable_text1.png

GUI Scrollable Text

Grid-Based Games

../_images/array_backed_grid1.png

Array-Backed Grid

../_images/array_backed_grid1.png

Array-Backed Grid Buffered

../_images/array_backed_grid1.png

Grid Using Sprites v1

../_images/array_backed_grid1.png

Grid Using Sprites v2

../_images/tetris.png

Tetris

../_images/conway_alpha.png

Conway’s Game of Life

Advanced

Using PyMunk for Physics

../_images/pymunk_box_stacks.png

Pymunk Physics Engine - Stacks of Boxes

../_images/pymunk_pegboard.png

Pymunk Physics Engine - Pegboard

../_images/pymunk_demo_top_down.png

Pymunk Demo - Top Down

../_images/pymunk_joint_builder.png

Pymunk Physics Engine - Joint Builder

../_images/pymunk_platformer.png

Pymunk Platformer

Frame Buffers

../_images/minimap1.png

Mini-Map

../_images/light_demo1.png

Lighting Demo

../_images/transform_feedback1.png

Transform Feedback

../_images/game_of_life_fbo1.png

Game of Life with Frame Buffers

Concept Games

../_images/asteroid_smasher.png

Asteroid Smasher

https://raw.githubusercontent.com/pythonarcade/asteroids/main/screenshot.png

Asteroids with Shaders

../_images/slime_invaders.png

Slime Invaders

../_images/community-rpg.png

Community RPG

../_images/2048.png

2048

../_images/rogue_like.png

Rogue-Like

Odds and Ends

../_images/sprite_collect_coins_background.png

Using a Background Image

../_images/timer.png

On-Screen Timer

../_images/performance_statistics1.png

Performance Statistics

../_images/text_loc_example_translated.png

Text Localization

Tutorials

../_images/11_animate_character.png

Simple Platformer

../_images/solitaire_11.png

Solitaire Tutorial

../_images/crt_filter.png

CRT Filter

../_images/raycasting_tutorial.png

Ray-casting Shadows

../_images/pymunk_platformer_tutorial.png

Pymunk Platformer

../_images/shader_toy_tutorial.png

Shader Toy Tutorial

Particle System

../_images/particle_fireworks.png

Particle System - Fireworks

../_images/particle_systems.png

Particle Systems

Stress Tests

../_images/stress_test_draw_moving.png

Draw Moving Sprites Stress Test

../_images/stress_test_collision.png

Collision Stress Test