Make your own "Choose Your Own Adventure" game. Use conditionals such as if
, else
, and elif
statements to lay out the logic and the story's path in your program.
To write your code according to my story, you can use this flow chart from draw.io to help you.
However, I think the fun part is writing your own story 😊
🧞♂️ 🐊 🧙♂️ 🧟 🧚♂️ 🧝♂️ 🥷 🤖 👽 🙀
That said if you'd like to continue with my example, feel free to use the text snippets below...
- 'You're at a crossroad. Where do you want to go? Type "left" or "right"'
- 'You've come to a lake. There is an island in the middle of the lake. Type "wait" to wait for a boat. Type "swim" to swim across.'
- "You arrive at the island unharmed. There is a house with 3 doors. One red, one yellow and one blue. Which colour do you choose?"
- "It's a room full of fire. Game Over."
- "You found the treasure! You Win!"
- "You enter a room of beasts. Game Over."
- "You chose a door that doesn't exist. Game Over."
- "You get attacked by an angry trout. Game Over."
- "You fell into a hole. Game Over."
If you want to use multiple sets of quotes inside a single string, you might have to "escape" some of them using the backslash \
. You can see this in my first sentence: 'You're at a crossroad...'. More on escaping characters here.
Have a think about how you might write your program to make a player's answers less case-sensitive. In other words, your code should work regardless of whether your user answers "left" or "Left".
You can also add your own ASCII art. Just remember to add three single quotes '''
at the start and at the end of your artwork to turn it into a multi-line string.