Lesson plan

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.

4 chapters, 7 lessons, about 5 hours, on the Raspberry Pi Pico. Every lesson runs in the browser, with nothing to install.

The unit

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.

Chapter 1. About 1 h 30 min

The screen

Draw pixels, boxes and text on a 128 by 64 OLED, then make a ship move with a game loop.

LessonTimeWhat 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
  1. Run it
  2. x across, y down
  3. Fill the ship
  4. Add a planet
  5. Your own title screen
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
  1. Run it
  2. Predict the bounce
  3. Twice as fast
  4. Up and down too
  5. Frames per second

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".

Chapter 2. About 1 h 20 min

Play

Steer with two buttons, catch stars with box collisions, and keep score.

LessonTimeWhat 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
  1. Hold A
  2. Hold B
  3. Faster steering
  4. Count taps, not frames
A scoreCatch stars with box collisions, keep score, draw it with % formatting, and end the game after three misses.40 min
  1. Catch one
  2. Boxes that touch
  3. Score on the screen
  4. Three misses and out

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".

Chapter 3. About 1 h 20 min

Danger and noise

A random asteroid field with lives and levels, and sound from a piezo.

LessonTimeWhat students do
Random enemiesAn asteroid field from random numbers and a list: spawn, move, clear away, crash. Then lives and levels.40 min
  1. Into the field
  2. Random, but the same
  3. Three lives
  4. It gets harder
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
  1. The start jingle
  2. A crash sound
  3. How low can it go?
  4. A tune as a list

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".

Chapter 4. About 55 min

Project: snake

Everything at once: a space snake with steering, food, growth, sound and warp edges.

LessonTimeWhat 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
  1. First bite
  2. Into the wall
  3. Steer it
  4. Faster as it grows
  5. Warp edges
  6. Make it yours

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".

Your class

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.