โ† Back to Python Course
๐ŸŽฎ Fun with Pythonยท25 minยทIntermediate
๐Ÿ—บ๏ธ

Text Adventures

Build a story game!

Learn how to build text-based adventure games where the player makes choices that change the story!

๐Ÿ“–

What we are learning

A text adventure is a game where the story is told through text. The player reads a situation, chooses what to do, and the story continues based on their choice. You will use if/else, input, and variables to create branching stories!

๐Ÿ’ก Think of it like this:

Think of a text adventure like a "Choose Your Own Adventure" book. You read a page, pick an option, and flip to a different page based on your choice. Each playthrough can be completely different!

๐ŸŒŸ

Why it matters

Text adventures combine everything you have learned: variables, if/else, loops, functions, and input. They are a fun way to practice all your skills while building something creative.

Where you see this in real life:

  • โœ“Interactive fiction games and visual novels
  • โœ“Educational simulations and training scenarios
  • โœ“Chatbot-style interactive experiences
๐ŸŽฏ

By the end, you can:

  • 1.Use if/elif/else for story branches
  • 2.Track player state with variables
  • 3.Use input() for player choices
๐Ÿ”ค

New words

branchstatechoicescenariopath
๐Ÿ
Imagine you are in a dark cave. You can go left or right. What happens if you go left? What about right?
๐Ÿค“

Fun Fact!

The first text adventure game was called "Colossal Cave Adventure" (1976). It had no graphics at all โ€” just text โ€” and players loved it!

๐Ÿ—บ๏ธ Text Adventures

A text adventure is a game where the story is told through text. The player reads a situation, chooses what to do, and the story changes based on their choice. You will use if/else, input, and variables to create branching stories!

๐Ÿ—๏ธ Step 1: Simple Story Branch

The simplest text adventure has one choice with two outcomes!

๐ŸYour first text adventure!
main.py
โ— Output
Click โ–ถ Run to see the output!

๐Ÿ—๏ธ Step 2: Multiple Choices

Let us add more choices and make the story longer!

๐ŸA bigger adventure!
main.py
โ— Output
Click โ–ถ Run to see the output!

๐Ÿ—๏ธ Step 3: Track Player State

Use variables to track things like health, inventory, and score!

๐ŸTrack health and inventory!
main.py
โ— Output
Click โ–ถ Run to see the output!
๐Ÿ
Try this: start planning your own adventure story! Write down 3 rooms and what choices the player has in each one.
๐Ÿง 

Quick Quiz!

+10 XP

What makes a text adventure game different from a regular story?

๐Ÿ
Finished the lesson? Click the button to mark it complete and earn XP!