- Learn Linux
- Learn Electronics
- Raspberry Pi
- LPI certification
- News & Reviews
Space Asteroids physical computing game written in Scratch or Python 3, using Pygame Zero and GPIO Zero
The game is a cross between Space Invaders and Asteroids. All the sprites are created from scratch in Blender and programmed to interact with electronic button switches and an LED.
Now Updated for Scratch Version 3
This worksheet is created for a version of the Space Asteroids game that is created in Scratch 3 on the Raspberry Pi.
It’s designed for those young and old who have preferably done a bit of Scratch programming before, but want to take first steps in physical computing or designing an interactive game. It’s also suitable for complete beginners to Scratch, who may need some help to get started with using Scratch.
You can also download the complete game of Space Asteroids (Scratch 3) for the Raspberry Pi.
The older version of the document (based around Scratch 2) is still available, although the Raspberry Pi no longer includes Scratch 2. It is therefore recommended that the newer Scratch 3 version is used instead.
Space Asteroid for Scratch version 2 (old version)
This worksheet is created for a version of the Space Asteroids game that is created in Pygame Zero (Python 3) on the Raspberry Pi.
This is designed for older students and adults that have already done some programming in Python, but want to learn about designing games in pygame zero or how to connect to simple electronics using gpio zero.
Version 1.2 - The code has been updated to use the same physical pins as the Scratch 3 version, so that both can be developed on the same Raspberry Pi without needing to rewire the GPIO pins.
You can download version 1.2 of the source code file: space-asteroids.py.txt. Note that the files has .txt added and should be saved as space-asteroids.py.
Version 2 (code only) - Additional code allows for the speed of the launcher to increase when the key / button is kept pressed. This means that it will take longer before it is not physically possible to move fast enough to fire at the asteroid. This is updated in the version 2 source code file only, it is not included in the worksheet.
You can download version 2.0 of the source code file: space-asteroids2.py.txt. Note that the files has .txt added and should be saved as space-asteroids.py2.
The image files used in the project are available from the link below.
Please view the copyright information regarding use of the circuits.