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_text1.png

Slow but Easy Text Drawing

../../_images/drawing_text_objects1.png

Better Text Drawing with Text Objects

../../_images/drawing_text_objects1.png

The Fastest Text Drawing: pyglet Batches

Animating Drawing Primitives

../../_images/bouncing_rectangle1.png

Bouncing Rectangle

../../_images/shapes.png

Bouncing Shapes

../../_images/radar_sweep.png

Radar Sweep

../../_images/snow1.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

Player Movement

../../_images/sprite_collect_coins.png

Move By Mouse

../../_images/sprite_collect_coins.png

Move By Keyboard

../../_images/sprite_collect_coins.png

Better Move By Keyboard

../../_images/sprite_collect_coins.png

Acceleration and Friction

../../_images/sprite_move_angle.png

Move By Turning

../../_images/sprite_face_left_or_right.png

Sprite: Face Left or Right

../../_images/sprite_collect_coins.png

Game Controller

../../_images/dual_stick_shooter1.png

Dual Stick Shooter

../../_images/turn_and_move.png

Move to Mouse Click

../../_images/sprite_rotate_around_tank.png

Move By Keyboard, Fire Towards Mouse

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

../../_images/sprite_rotate_around_point.png

Sprite Rotation Around a Point

Easing

../../_images/easing_example_11.png

Easing Example 1

../../_images/easing_example_21.png

Easing Example 2

Calculating a Path

../../_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

Audio

Sound Effects

../../_images/sound_demo.png

Sound Demo

../../_images/sound_speed_demo.png

Sound Speed Demo

Music

../../_images/music_control_demo.png

Music Control Demo

Display Management

Resizable Windows

../../_images/resizable_window.png

Resizable Window

../../_images/full_screen_example1.png

Full Screen Example

Backgrounds

../../_images/sprite_collect_coins_background.png

Using a Background Image

../../_images/background_parallax1.png

Parallax

Cameras

../../_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

../../_images/camera_platform1.png

Camera Use in a Platformer

View Management

Instruction 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

Sectioning a View

../../_images/sections_demo_1.png

Sections Demo 1

../../_images/sections_demo_2.png

Sections Demo 2

../../_images/sections_demo_3.png

Sections Demo 3

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

Tiled Map Editor

../../_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

Graphical User Interface

../../_images/gui_flat_button1.png

Flat Text Buttons

../../_images/gui_flat_button_styled.png

Flat Text Button Styled

../../_images/gui_widgets1.png

GUI Widgets

../../_images/gui_ok_messagebox1.png

OK Message Box

../../_images/gui_scrollable_text1.png

GUI Scrollable Text

../../_images/gui_slider1.png

GUI Slider

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/minimap.png

Mini-Map

../../_images/light_demo.png

Lighting Demo

../../_images/transform_feedback.png

Transform Feedback

../../_images/game_of_life_fbo1.png

Game of Life with Frame Buffers

../../_images/perspective.png

Perspective

OpenGL

../../_images/normal_mapping.png

Normal Mapping

../../_images/spritelist_interaction_visualize_dist_los.png

GPU Based Line of Sight

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/timer.png

On-Screen Timer

../../_images/performance_statistics.png

Performance Statistics

../../_images/text_loc_example_translated.png

Text Localization

Particle System

../../_images/particle_fireworks.png

Particle System - Fireworks

../../_images/particle_systems.png

Particle Systems

Tutorials

../../_images/intro_screen.png

Simple Platformer

../../_images/solitaire_11.png

Solitaire

../../_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 - Glow

Stress Tests

../../_images/stress_test_draw_moving.png

Draw Moving Sprites Stress Test

../../_images/stress_test_collision.png

Collision Stress Test