Treasure Island Game program in Python

Table of contents

No heading

No headings in the article.

Hello World !

We all love to play games. Games are escape from world and it boost confidence with the achievements. So, I thought to tweak the programming concepts with games.

What is Treasure Island Game ?

Treasure Island is a game of bluffing and adventure in which one player speculate hit and try, to in their search for his treasure.

How to create Treasure Island Program

Lets start with coding .

image.png

Step 1 :

We are using ASCII art to make program more user friendly. To get your customise art. Check : ASCII art

Note: Always include ASCII art as a multiline string : Use triple quotes to create a multiline string.

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_.--""___/______/______/______/____
/______/______/______/______/______/______/______/______/______/______/_____ /
*******************************************************************************
''')

Step 2:

Greet the user using print function.

print("Welcome to Treasure Island.")
print("Your mission is to find the treasure.")

Step 3: Ask the user for his choice

user_input=input("Do you want to turn left or right").lower()

Step 4: Use conditional statement to make decision. Please find the prototype below:

if (condition==true):
   execute thise
else:
execute this

Here we have multiple condition to check therefore using Multiple Ifs

if user_input=='left':
    user_input=input("You have reached a mountain full of wild animals. Do you want to move or stay").lower()


        if user_input=='move':
                    user_input=input("You have came across a hut. There are three colour gates: red, yellow, green. Choose one").lower()

                     if (user_input == 'red'):
                            print("You are captured! Game Over")
                    elif (user_input == 'green'):
                             print("You found the palace. Congrats you won !!")
                    else:
                             print("You reached house full of harmful gases. Game Over")]
    else:
        print("You got caught by wild animals and You Loose")
else:
    print("You Loose")

With these steps, we have successfully create prime number program using python. That's it!

I hope you find it helpful.

You can find the copy of program on my github :Samra

Please connect with me on my LinkedIn :Samra-Qureshi