Before you begin, make sure you have the following tools installed on your computer:
- A text editor (such as Sublime Text or Atom)
- Python 3
Open your text editor and create a new file. Save the file as ascii_art_game.py
.
The first thing we need to do is add the ASCII art to our file. Copy the following block of code and paste it into your file:
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_.--""___/______/______/______/____
/______/______/______/______/______/______/______/______/______/______/_____ /
*******************************************************************************
''')
print("Welcome to Treasure Island.")
print("Your mission is to find the treasure.")
This block of code will print the ASCII art and a welcome message to the console when the game is run.
Next, we will add the first input and conditional statement. This will allow the player to choose a direction and determine the next step in their journey.
Copy the following block of code and paste it into your file:
first_que = input('where would you love to go, left or right?')
if first_que.lower() == 'right': print('Game Over') elif first_que.lower() == 'left': second_que = input('would you love to swim or wait?') print(second_que) if second_que.lower() == 'swim': print('Game Over, you drowned') elif second_que.lower() == 'wait': third_que = input('which door would you love to follow, blue, red or yellow?')
print(third_que) if third_que.lower() == 'blue': print('Game Over, you got burnt') elif third_que.lower() == 'red': print('Game Over, you got burnt') elif third_que.lower() == 'yellow': print('Congratulation, you made it. You won!!!') else: print('Game Over, you lost') else: print('Game Over, you drowned')
else: print('Game Over')
This block of code will prompt the player to choose a direction (left or right). If the player chooses left, they will be asked whether they want to swim or wait. If they choose swim, the game will end and they will have drowned. If they choose wait, they will be asked to choose a door (blue, red, or yellow). If they choose blue or red, the game will end and they will be burnt. If they choose yellow, they will win the game and find the treasure!
To test the game, open a terminal window and navigate to the directory where you saved the file. Then, run the following command:
python ascii_art_game.py
The game should now be running, and you can follow the prompts to play through the adventure.
You can customize the game by modifying the ASCII art, the prompts, and the outcome of the different choices. Have fun experimenting with different combinations and creating your own unique adventure!