This commit is contained in:
wittmannzl103469 committed 2026-11-05 15:08:42 +01:00
1 parent de41a02749
commit 9af09cebd3
764 files changed
+54218 -78859

No files matched your search

@@ -1,145 +1,154 @@
These examples should help get you started with pygame. Here is a
brief rundown of what you get. The source code for all examples
is in the public domain. Feel free to use for your own projects.
These examples are a good introduction to various Pygame modules and
techniques. They are beginner-friendly with source code in the public
domain that can be adapted for your projects.
aacircles.py
An example of using the gfxdraw module to drawing anti-aliased circles.
aliens.py
This started off as a port of the SDL demonstration, Aliens.
Now it has evolved into something sort of resembling fun.
This demonstrates a lot of different uses of sprites and
optimized blitting. Also transparency, colorkeys, fonts, sound,
music, joystick, and more. (PS, my high score is 117! goodluck)
An arcade-style space shooter game that showcases various common and
important Pygame modules and techniques.
arraydemo.py
Another example filled with various surfarray effects.
It requires the surfarray and image modules to be installed.
This little demo can also make a good starting point for any of
your own tests with surfarray
Showcases the use of Numpy with Pygame to perform efficient
pixel manipulation.
audiocapture.py
Record sound from a microphone, and play back the recorded sound.
Use the mixer module to record sound from a microphone, and
play back the recorded sound.
blend_fill.py
BLEND_ing colors in different ways with Surface.fill().
Demonstrates how to perform surface blending and filling
with Pygame.
blit_blends.py
BLEND_ing colors Surface.blit().
Uses blit functions to showcase some of Pygame's different
blending modes.
camera.py
Basic image capturing and display using pygame.camera
chimp.py
A simple game featuring a chimp that showcases the use of
common and important Pygame modules and techniques.
cursors.py
Make custom cursors :)
Demonstrates the creation of custom cursors with Pygame.
dropevent.py
Drag and drop files. Using the following events.
Drag and drop files using the following events:
DROPBEGIN, DROPCOMPLETE, DROPTEXT, DROPFILE
eventlist.py
Learn about pygame events and input.
Watch the events fly by. Click the mouse, and see the mouse
event come up. Press a keyboard key, and see the key up event.
A utility for displaying and logging real-time Pygame events,
useful for debugging.
font_viewer.py
Display all available fonts in a scrolling window.
Demonstrates how to display all available fonts in a
scrolling window.
fonty.py
Super quick, super simple application demonstrating
the different ways to render fonts with the font module
A simple application demonstrating the different ways
to render fonts with the font module
freetype_misc.py
FreeType is a world famous font project.
Shows how to use the freetype module to perform font
rendering and manipulation.
glcube.py
Using PyOpenGL and Pygame, this creates a spinning 3D multicolored cube.
go_over_there.py
Demonstrates Vector.move_towards.
Demonstrates the important Vector.move_towards() function.
grid.py
A simple example of grid-based movement.
headless_no_windows_needed.py
For using pygame in scripts.
Shows how to run Pygame in scripts.
joystick.py
Shows how to integrate joysticks or game controllers into Pygame.
liquid.py
This example was created in a quick comparison with the
BlitzBasic gaming language. Nonetheless, it demonstrates a quick
8-bit setup (with colormap).
Demonstrates how to create a simple liquid effect in an image.
mask.py
Single bit pixel manipulation. Fast for collision detection,
and also good for computer vision.
Showcases how to use masks for collision detection and sprite
interaction.
midi.py
For connecting pygame to musical equipment.
Demonstrates how to use MIDI I/O using the midi module.
moveit.py
A very simple example of moving stuff.
Illustrates how to accomplish sprite movement and animation.
music_drop_fade.py
Fade in and play music from a list while observing
several events. Uses fade_ms added in pygame2, as well as set_endevent,
set_volume, drag and drop events, and the scrap module.
ninepatch.py
Demonstrate the purpose of the 9-patch scale method and a way to implement it.
Showcases dropping music files into Pygame, and how to
apply a fade effect to music playback.
pixelarray.py
Process whole arrays of pixels at a time.
Like numpy, but for pixels, and also built into pygame.
Manipulation of individual pixels using the PixelArray module.
playmus.py
Simple music playing example.
Uses the mixer module to play music files with CLI.
prevent_display_stretching.py
A windows specific example.
Illustrates how to maintain aspect ratio when resizing a window
in Pygame.
resizing_new.py
Showcases various window resizing events and how to fit graphics
to new dimensions.
scaletest.py
Showing how to scale Surfaces.
Showcases the scaling of Surfaces.
scrap_clipboard.py
A simple demonstration example for the clipboard support.
Shows how to implement clipboard interaction with Pygame's scrap module.
scroll.py
An example that implements smooth scrolling backgrounds for side-scrolling
games or parallax effects.
setmodescale.py
SCALED allows you to work in 320x200 and have it show up big.
It handles mouse scaling and selection of a good sized window depending
Handles mouse scaling and selection of a good sized window depending
on the display.
sound.py
Extremely basic testing of the mixer module. Load a
sound and play it. All from the command shell, no graphics.
Illustrates how to implement sound effects and music using Pygame.
sound_array_demos.py
Echo, delay and other array based processing of sounds.
Showcases echo, delay and other array based processing of sounds.
sprite_texture.py
Shows how to use hardware Image Textures with pygame.sprite.
Demonstrates how to use textured sprites in Pygame.
stars.py
A simple starfield example. You can change the center of
perspective by leftclicking the mouse on the screen.
A simple starfield implementation in which the perspective can be
changed by a mouse click.
testsprite.py
More of a test example. If you're interested in how to use sprites,
then check out the aliens.py example instead.
Showcases the basics of sprite handling, namely collision
detection and animation.
textinput.py
A little "console" where you can write in text.
Shows how to use the TEXTEDITING and TEXTINPUT events.
vgrade.py
Demonstrates creating a vertical gradient with
Numpy. The app will create a new gradient every half
second and report the time needed to create and display the
image. If you're not prepared to start working with the
Numpy arrays, don't worry about the source for this one :]
Shows how to apply vertical gradients to surfaces using Pygame.
video.py
It explores some new video APIs in pygame 2.
Including multiple windows, Textures, and such.
Showcases the movie module, including the display of playback
controls.
data/
Directory with the resources for the examples.
There's LOTS of examples on the pygame website, and on places like github.
We're always on the lookout for more examples and/or example
requests. Code like this is probably the best way to start
getting involved with Python gaming.
More examples can be found on the Pygame website and GitHub.
We're always looking for new examples and/or example requests. Examining
code such as this is a great way to get started with Python-based
game development.