Game dev on microcontrollers lesson plan
Write a space platformer in C++ on an ESP32-C3 with a tiny OLED, three buttons and a piezo: game loop, sprites, input, collision, gravity and sound, one idea at a time.
Objectives and materials
By the end, students can
- A steady frame rate and sprites stored as bytes.
- Buttons read like a game reads them, and boxes that touch.
- Fixed-point gravity and sound effects that never freeze the game.
- Everything in one platformer, then a level of your own.
Materials for the whole unit
- ESP32-C3-DevKitM-1
- Full-size breadboard
- OLED display, 128x64
- Piezo speaker
- Pushbutton x 3
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.
Loop and pictures
A steady frame rate and sprites stored as bytes.
| Lesson | Time | What students do |
|---|---|---|
| The game loopRead, update, draw, wait: a parallax starfield at a fixed 25 frames a second, a frame budget you can measure, and what happens when the work outgrows it. | 50 min |
|
| Sprites and framesAn 8x8 astronaut stored as eight bytes, a two-frame walk cycle, a mirrored turn that costs no memory, and erasing exactly what you drew. | 50 min |
|
Materials
- ESP32-C3-DevKitM-1
- Full-size breadboard
- OLED display, 128x64
- Piezo speaker
- Pushbutton x 3
Check for understanding
Each student finishes "Sprites and frames" 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: "Walk faster".
Make it playable
Buttons read like a game reads them, and boxes that touch.
| Lesson | Time | What students do |
|---|---|---|
| InputThree buttons read once a frame into a snapshot: held for walking, pressed for jumping, and why reading once a frame also tames contact bounce. | 40 min |
|
| CollisionAxis-aligned boxes and four comparisons: collect crystals, stop at a boulder by undoing the move, and tune a hitbox until the game feels fair. | 40 min |
|
Materials
- ESP32-C3-DevKitM-1
- Full-size breadboard
- OLED display, 128x64
- Piezo speaker
- Pushbutton x 3
Check for understanding
Each student finishes "Collision" 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: "Tune the hitbox".
Physics and sound
Fixed-point gravity and sound effects that never freeze the game.
| Lesson | Time | What students do |
|---|---|---|
| GravityVelocity, acceleration and sixteenths of a pixel: a jump that is a true parabola, moon gravity in one constant, and landing on a ledge from above. | 40 min |
|
| Sound effectsA piezo, tone() and note tables: a start jingle, a rising jump and a crystal chime, played from the game loop by priority without ever freezing the game. | 40 min |
|
Materials
- ESP32-C3-DevKitM-1
- Full-size breadboard
- OLED display, 128x64
- Piezo speaker
- Pushbutton x 3
Check for understanding
Each student finishes "Sound effects" 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: "Design your jump".
Boss
Everything in one platformer, then a level of your own.
| Lesson | Time | What students do |
|---|---|---|
| Boss: a platformerEverything in one game: three crystals on the moon, floating rocks, a crater that costs a life and a portal that opens when you have them all. Then make it yours. | 50 min |
|
Materials
- ESP32-C3-DevKitM-1
- Full-size breadboard
- OLED display, 128x64
- Piezo speaker
- Pushbutton x 3
Check for understanding
Each student finishes "Boss: a platformer" 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: "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.