Bodgers – Pygame Zero

This week we took a break from hardware and we looked at Pygame Zero. Pygame Zero is for creating games quickly and with fewer lines of code than would be used with Pygame. It is intended for use in education, so we can learn basic programming without needing to understand the Pygame API or how to write an event loop.

Pygame Zero is designed for the Raspberry Pi but it can be installed on other systems, we used Windows without much hassle. It comes installed on the Raspberry Pi already if you have a recent version of Raspian. To install on windows open a command prompt and type:

pip install pgzero

You may need to install Pip if you didn’t install it when you installed Python. To do this go to Control Panel/Settings and then Add/Remove Programs, scroll down and click on Python then click on modify, tick the Pip check box and save your changes.

To run your code from Idle or any other IDE you need to add two lines to your code, at the beginning before any other code you need:

import pgzrun

and at the  end of your code put:


We will be using Pygame Zero for graphical input/output in our projects but if you want to have a go at writing a game, CodeConjuring’s Froggit youtube tutorials are a good place to start.


See you all next week.

Declan, Dave and Alaidh.