Lesson 5.6: Adventure Game Pt. 1

Today’s Goals

  • Begin building a text-based Adventure Game
  • Practice branching with conditionals (if/elif/else)
  • Write a storyline with choices that affect the outcome

Warm-Up Question

  • What’s your favorite type of adventure?
    (Fantasy, mystery, survival, sci-fi, etc.)

Adventure Game Basics

  • The player makes choices
  • Each choice leads to a different outcome
  • Use input() to ask the player what they want to do

Simple Example

print("You are in a dark cave.")
choice = input("Do you go left or right? ")

if choice == "left":
    print("You find treasure!")
elif choice == "right":
    print("A monster attacks!")
else:
    print("You stand still and hear noises...")

Discussion

  • Why is elif useful here?
  • What happens if the player types something unexpected?

Student Challenge

  • Write a 5-step adventure with at least 2 endings
  • Each step should ask the player for a choice

Bonus

  • Add a hidden “secret path” option that surprises the player

Wrap-Up

  • Adventure games show how code can create interactive stories
  • Next time: We’ll organize adventures into functions