My Fourth Python Project: Coding a Treasure Hunt Game

Gautam MallickGautam Mallick
3 min read

Coding a Treasure Hunt Game

Hello, fellow coders! 👋

After building a roller coaster system and a pizza order system, I decided to dive into something even more adventurous: a Treasure Hunt Game! 🏴‍☠️

This project is not just a game—it's a way to practice decision-making in Python while having a bit of fun. Let's walk through the code and see how you can create your own treasure hunt adventure.

Flow Chart

The Code

Here's the complete Python code for the treasure hunt game:

print('''
*******************************************************************************
          |                   |                  |                     |
 _________|________________.=""_;=.______________|_____________________|_______
|                   |  ,-"_,=""     `"=.|                  |
|___________________|__"=._o`"-._        `"=.______________|___________________
          |                `"=._o`"=._      _`"=._                     |
 _________|_____________________:=._o "=._."_.-="'"=.__________________|_______
|                   |    __.--" , ; `"=._o." ,-"""-._ ".   |
|___________________|_._"  ,. .` ` `` ,  `"-._"-._   ". '__|___________________
          |           |o`"=._` , "` `; .". ,  "-._"-._; ;              |
 _________|___________| ;`-.o`"=._; ." ` '`."\` . "-._ /_______________|_______
|                   | |o;    `"-.o`"=._``  '` " ,__.--o;   |
|___________________|_| ;     (#) `-.o `"=.`_.--"_o.-; ;___|___________________
____/______/______/___|o;._    "      `".o|o_.--"    ;o;____/______/______/____
/______/______/______/_"=._o--._        ; | ;        ; ;/______/______/______/_
____/______/______/______/__"=._o--._   ;o|o;     _._;o;____/______/______/____
/______/______/______/______/____"=._o._; | ;_.--"o.--"_/______/______/______/_
____/______/______/______/______/_____"=.o|o_.--""___/______/______/______/____
/______/______/______/______/______/______/______/______/______/______/[TomekK]
*******************************************************************************
''')
print("\n\nWelcome to the treasure Island\n\n")
print("Your mission is to find the treasure \n ")
choice_1 = input('You\'re at the Crossroad, Where do you want to go? Type to go "left" or "right": ')

if choice_1.lower() == "right":
    choice_2 = input('A big lake...An island in the middle of the lake...Type to "swim" or "wait" for the boat :? \n')
    if choice_2.lower() == "wait":
        choice_3 = input("Which door do you want to choose? Red or blue or yellow:? \n")
        if choice_3.lower() == "yellow":
            print("Eureka! You have won the treasure!!")
        else:
            print("The door is locked! You are being attacked by zombies! Keep trying your luck.")
    else:
        print("You swim in shark-infested waters! You're dead. Restart your treasure hunt.")
else:
    print("Game Over! Rise from the ashes and restart. There's never a Game Over!\n")

How It Works

1. The Journey Begins

The game starts with a classic crossroads scenario—go left or right? Depending on your choice, the adventure unfolds in different ways.

2. The Lake and the Island

If you choose the right path, you’ll find yourself facing a big lake. You can either swim across (risking shark attacks!) or wait for a boat to take you to the island.

3. The Final Challenge

Once you reach the island, you have to pick the right door—red, blue, or yellow. Choose wisely, and you might just find the treasure! But beware—wrong choices have consequences!

What I Learned

  • Decision-making in Python: This project gave me hands-on experience with if-else statements and how to handle user input in a fun way.

  • String Methods: I used .lower() to make sure the game accepts both upper and lower case inputs, keeping things simple for players.

  • ASCII Art: I discovered a cool website called ascii.co.uk for generating fun ASCII art to make the game more visually appealing.

Try It Out!

If you're new to Python or looking for a fun way to practice, I encourage you to try coding this game. You can add your own twists—like more challenges, different endings, or even a backstory for the treasure!

Conclusion

This project reminded me that coding doesn’t always have to be serious. Sometimes, it’s about having fun and letting your imagination run wild. 🎉

Give it a try, and let me know in the comments if you find the treasure or end up as shark bait! 🦈

Happy coding, and stay tuned for more Python adventures! 🚀


A Special Thanks 🙏
Before I sign off, I want to extend a heartfelt thank you to Dr. Angela Yu for creating such an amazing course in the 100 Days of Code: The Complete Python Pro Bootcamp. Your teaching has made learning Python an absolute joy and has inspired me to explore coding in creative ways. 🚀

0
Subscribe to my newsletter

Read articles from Gautam Mallick directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Gautam Mallick
Gautam Mallick

I'm an SRE/DevOps engineer with 11 years of experience, dedicated to mastering and sharing knowledge in tech. Outside of work, I love to travel, have fun with friends, and stay on top of the latest technologies. Rock music keeps me energized as I continue my journey in tech, and I'm always eager to connect with others who share similar passions.