Capstone: A Text Adventure
You’ve reached the end of Phase II! You can talk to the user, work with words and numbers, make decisions, repeat with loops, and store data in lists and dictionaries. Time to combine all of it into a text adventure — a story where the player’s choices change what happens.
How a branching story works
At each step, you describe a scene, ask for a choice, and use if/elif to decide what comes next. Here’s a single fork:
That’s the whole engine: describe, ask, branch. String a few of these together and you have a game.
Choices inside choices
Decisions can nest — a choice can lead to another choice:
Carrying an inventory
Use a list to track what the player collects, and check it later with in:
See how Phase II all shows up: input, if/else, .lower(), a list, .append(), and in. That’s a real little game built from the pieces you learned.
Build your own adventure 🚀
Now write your story. Start from this skeleton and grow it — add scenes, choices, items, and at least two different endings (one good, one bad). Make it about anything: space, a haunted house, a video game world.
Tip: build it a scene at a time and Run often. Big games are just small scenes connected by choices.
What you learned in Phase II
You started Phase II only able to draw. Now you can build real programs that think and talk:
- Talk:
printandinputto message the user. - Words & numbers: strings, math, and converting input with
int(). - Logic: booleans, comparisons, and
if/elif/else. - Repetition:
whileloops that run until something changes. - Data: lists and dictionaries to store collections, and
forloops to process them. - Functions that
returnanswers you can reuse.
Those last few — lists, dictionaries, looping through data, and functions — are exactly the tools real programmers use to work with data.
What’s next: Phase III
In Phase III, you put everything together and build real video games — a player you steer with the arrow keys, stars to catch, asteroids to dodge, a score ticking up — using a games library called pygame, right here in your browser (nothing to install, just like now). Every game runs on exactly what you already know: loops, if logic, lists, and functions. (After that, Phase IV makes you a data detective, and Phase V gives you a first taste of AI.)
You started the summer drawing a single line with a turtle. Now you can build programs that think and talk — and next, games you can play and share. See you in Phase III! 🎮
Comments