All paths

Python games in the terminal

Build a text adventure on a derelict space station, one real game system at a time: branching stories, dice, state, saves, a map of rooms, enemies with rules, and a boss crawler with alarms on the Pi.

Raspberry Pi 4 Model BFree7 lessons5 h4 chapters1,835 XPCoding · Beginner+100 XP

0 of 7 done

What you will build

3 projects, built step by step

7 lessons in 4 chapters, about 5 hours on a simulated Raspberry Pi 4 Model B. Free, in your browser, every step checked by the simulator.

Chapter 1 project

Random and dice

Let chance into the game: random.randint for dice, a seed that makes the same rolls every run, a roll() function for 2d6 skill checks, the odds counted out of 36 and then measured over 3600 rolls, random.choice for loot, and a yellow light for a critical success.

Open it in the simulator
Chapter 2 project

Save and load

Turn the game state into text with json, write it to a file and read it back, handle the first run when there is no save yet, add save and load commands that work as a time machine, and autosave every third turn with the % operator.

Open it in the simulator
Chapter 3 project

Enemies with simple rules

Put things in the dark that fight back: an enemy as a dict, a fight loop that takes turns, a coward that flees when hurt, a table of enemies whose behavior comes from a rule name, a fight where you choose each move, and a red danger light when your hp gets low.

Open it in the simulator
The map

Chapter by chapter

Each lesson opens when the one before it is done, and each chapter ends in a project.

Chapter 1

Stories and chance

Read the player, branch the story, and let dice decide.

  1. Open190 XP

    A story that branches

    Start a text adventure on a derelict space station: read the player's answer with input(), clean it so " NORTH " still works, branch with if, elif and else, nest choices into a story tree, loop until the answer makes sense, and light a red alarm.

    0 of 6 steps

  2. ProjectLocked380 XP

    Random and dice

    Let chance into the game: random.randint for dice, a seed that makes the same rolls every run, a roll() function for 2d6 skill checks, the odds counted out of 36 and then measured over 3600 rolls, random.choice for loot, and a yellow light for a critical success.

    0 of 6 steps

5 questions, graded as you go.
Chapter 2

State that lasts

Keep the game in a dict, then save it to a file and load it back.

  1. Locked190 XP

    Game state in a dict

    Keep everything the game knows in one dict: a status line built from it, functions that change it, an inventory list inside it, a command loop that drives it, an oxygen alarm on the red LED, and a game over when the air runs out.

    0 of 6 steps

  2. ProjectLocked330 XP

    Save and load

    Turn the game state into text with json, write it to a file and read it back, handle the first run when there is no save yet, add save and load commands that work as a time machine, and autosave every third turn with the % operator.

    0 of 5 steps

5 questions, graded as you go.
Chapter 3

A world to explore

Make the station data, then fill it with enemies that follow rules.

  1. Locked190 XP

    A map of rooms

    Stop writing the story as nested ifs and make the station data: a dict of rooms, each with a description and a dict of exits. Describe a room with sorted exits, walk between rooms in a loop, add a room without touching the code, lock a door behind a keycard, and count the rooms explored with a set.

    0 of 6 steps

  2. ProjectLocked380 XP

    Enemies with simple rules

    Put things in the dark that fight back: an enemy as a dict, a fight loop that takes turns, a coward that flees when hurt, a table of enemies whose behavior comes from a rule name, a fight where you choose each move, and a red danger light when your hp gets low.

    0 of 6 steps

5 questions, graded as you go.
Chapter 4

Boss

Every system in one game: the Tycho-9 station crawler.

  1. Locked175 XP

    Boss: a station crawler

    The finale: one game with everything. A map of six rooms, guards that fight by their rules, oxygen that runs down with a red alarm, a keycard door and a fuse that restarts the reactor and lights the yellow LED, and a save that stores the whole world, not just the player.

    0 of 6 steps

3 questions, graded as you go.
Syllabus

Every lesson in the course

All 7 lessons, in order, each with what it covers. Any of them opens in the editor right away.

Chapter 1

Stories and chance

  1. A story that branchesStart a text adventure on a derelict space station: read the player's answer with input(), clean it so " NORTH " still works, branch with if, elif and else, nest choices into a story tree, loop until the answer makes sense, and light a red alarm.
  2. Random and diceLet chance into the game: random.randint for dice, a seed that makes the same rolls every run, a roll() function for 2d6 skill checks, the odds counted out of 36 and then measured over 3600 rolls, random.choice for loot, and a yellow light for a critical success.
Chapter 2

State that lasts

  1. Game state in a dictKeep everything the game knows in one dict: a status line built from it, functions that change it, an inventory list inside it, a command loop that drives it, an oxygen alarm on the red LED, and a game over when the air runs out.
  2. Save and loadTurn the game state into text with json, write it to a file and read it back, handle the first run when there is no save yet, add save and load commands that work as a time machine, and autosave every third turn with the % operator.
Chapter 3

A world to explore

  1. A map of roomsStop writing the story as nested ifs and make the station data: a dict of rooms, each with a description and a dict of exits. Describe a room with sorted exits, walk between rooms in a loop, add a room without touching the code, lock a door behind a keycard, and count the rooms explored with a set.
  2. Enemies with simple rulesPut things in the dark that fight back: an enemy as a dict, a fight loop that takes turns, a coward that flees when hurt, a table of enemies whose behavior comes from a rule name, a fight where you choose each move, and a red danger light when your hp gets low.
Chapter 4

Boss

  1. Boss: a station crawlerThe finale: one game with everything. A map of six rooms, guards that fight by their rules, oxygen that runs down with a red alarm, a keycard door and a fuse that restarts the reactor and lights the yellow LED, and a save that stores the whole world, not just the player.
Kits

Build it on your bench too

Every lesson runs in the simulator with nothing to buy. When you want the real thing, these kits have the parts.

Have a kit already?

Find your kit

Pick the starter kit you own and run every lesson in its manual with the same parts on the same pins.

See every kit
Questions

About Python games in the terminal

Is Python games in the terminal free?

Yes. All 7 lessons of Python games in the terminal are free and run in your browser, with nothing to install and no parts to buy before you start.

Do I need a real Raspberry Pi 4 Model B?

No. Every lesson runs on a simulated Raspberry Pi 4 Model B with its parts on the canvas, and the simulator checks each step as you go. When you want to build it for real, the same wiring and code work on a real board.

How long does Python games in the terminal take?

About 5 hours: 7 lessons in 4 chapters, each one a few short steps. Your progress is kept, so you can stop after any lesson and pick up where you left off.

What will I build?

Each chapter ends in a project that puts it together: Random and dice, Save and load and Enemies with simple rules.

Where do I start?

With "A story that branches", and each lesson builds on the one before it. New to circuits? Electronics basics is the course that starts from zero.