MicroPython games on a tiny screen lesson plan
Build space games in MicroPython on a Pico with an OLED: drawing, a game loop, buttons, a score, random asteroids, sound, and a space snake.
Objectives and materials
By the end, students can
- Draw pixels, boxes and text on a 128 by 64 OLED, then make a ship move with a game loop.
- Steer with two buttons, catch stars with box collisions, and keep score.
- A random asteroid field with lives and levels, and sound from a piezo.
- Everything at once: a space snake with steering, food, growth, sound and warp edges.
Materials for the whole unit
- OLED display, 128x64
- Piezo speaker
- Pushbutton x 2
- Raspberry Pi Pico
Every part is already on the simulator’s bench, so there is nothing to buy or hand out. The counts are the most any one lesson uses, if you build it on real breadboards too.
The screen
Draw pixels, boxes and text on a 128 by 64 OLED, then make a ship move with a game loop.
| Lesson | Time | What students do |
|---|---|---|
| Drawing on an OLEDLight pixels, lines, boxes and text on a 128 by 64 OLED, and learn why nothing shows until show(). | 45 min |
|
| Moving a dotThe game loop every game runs: clear, draw, show, move. Bounce a ship off the walls and measure your frame rate. | 45 min |
|
Materials
- OLED display, 128x64
- Piezo speaker
- Pushbutton x 2
- Raspberry Pi Pico
Check for understanding
Each student finishes "Moving a dot" on their own, without opening the hints. The simulator checks 5 of its 5 steps as they go.
Then ask each one to explain, in a sentence or two, the last thing it asked of them: "Frames per second".
Play
Steer with two buttons, catch stars with box collisions, and keep score.
| Lesson | Time | What students do |
|---|---|---|
| Reading buttonsSteer the ship with two buttons: pull-ups, why pressed reads 0, held versus tapped, and the bounce you never see. | 40 min |
|
| A scoreCatch stars with box collisions, keep score, draw it with % formatting, and end the game after three misses. | 40 min |
|
Materials
- OLED display, 128x64
- Piezo speaker
- Pushbutton x 2
- Raspberry Pi Pico
Check for understanding
Each student finishes "A score" on their own, without opening the hints. The simulator checks 4 of its 4 steps as they go.
Then ask each one to explain, in a sentence or two, the last thing it asked of them: "Three misses and out".
Danger and noise
A random asteroid field with lives and levels, and sound from a piezo.
| Lesson | Time | What students do |
|---|---|---|
| Random enemiesAn asteroid field from random numbers and a list: spawn, move, clear away, crash. Then lives and levels. | 40 min |
|
| SoundMake a piezo sing with PWM: a start jingle, a crash sound, the lowest note the Pico can make, and a tune stored as a list. | 40 min |
|
Materials
- OLED display, 128x64
- Piezo speaker
- Pushbutton x 2
- Raspberry Pi Pico
Check for understanding
Each student finishes "Sound" on their own, without opening the hints. The simulator checks 4 of its 4 steps as they go.
Then ask each one to explain, in a sentence or two, the last thing it asked of them: "A tune as a list".
Project: snake
Everything at once: a space snake with steering, food, growth, sound and warp edges.
| Lesson | Time | What students do |
|---|---|---|
| Project: snakeBuild space snake: a grid, a list of cells for a body, two-button steering, food, growth, sound, speed-ups and warp edges. | 55 min |
|
Materials
- OLED display, 128x64
- Piezo speaker
- Pushbutton x 2
- Raspberry Pi Pico
Check for understanding
Each student finishes "Project: snake" on their own, without opening the hints. The simulator checks 6 of its 6 steps as they go.
Then ask each one to explain, in a sentence or two, the last thing it asked of them: "Make it yours".
Teach this unit as a class
Start a class from this course and its 7 lessons are assigned in one go, in order. Students join with a six-character code or printed login cards, and each one’s work comes back to you.
The class tools are free for 30 days for one class of up to 20 students, with no card. The lessons themselves are free either way.