Making Games with Python: Pygame Zero
What are we making today?
Like its predecessor, Pygame, but modernised, and simplified.
Unix is made of lots of small programs… all wired together
pip install pgzero
pip3 install pgzero
💡 If you haven’t got pip or pip3 (you should) then https://pip.pypa.io/en/stable/installation/
Before we start… python2 and python3 ways to install PyGameZero
Also… what even is python?
other package managers exist, conda, poetry, npm, brew,
A Warning From The Future
These slides contain a very brief introduction to the command line, and to Virtual Environments in Python.
just learn 2 lines of code!!!
Four Ways To Code With PyGame Zero
Make a copy of this template. It contains images, font, and sounds folders with files already created. The main.py is the one that runs. The space_invaders.py is completed code.
Note: Sounds won't work.
Terminal / Powershell
Visual Studio Code
(VS Code)
an IDE
(Integrated Development Environment)
Repl.it (online)
A great IDE for beginners with a pgzero built-in mode
Get the example files are here:
sessions_games.zip includes 3 example games.py files and the images,sounds and font used in the games for this session.
Also get some documentation open.
import pgzrun
WIDTH = 800
HEIGHT = 600
text = "Hello World!"
def draw():
screen.clear()
screen.fill((50, 40, 70))
screen.draw.text(text, (20, 20), fontsize=40, color="lime")
pgzrun.go()
Let’s look at intro.py
A more fleshed out version of a game that has…
Let’s look at space_invaders.py
Next Steps … better games, tutorials.
An excellent few game tutorials (with graphics packs to download too)
I like this tutorial as it goes through each step AND gives you graphics to work with.
More Learning Resources
Go try tutorials or find game examples and tweak them, subvert them to learn how it works and build your coding skills.
Other ways to make games, previous Digital Wednesdays…