Certainly! Here's a simple text-based adventure game code example in Python:
```python
import time
def adventure_game():
print("Welcome to the Adventure Game!")
time.sleep(2)
print("You are in a mysterious forest.")
time.sleep(2)
print("Your goal is to find a hidden treasure.")
time.sleep(2)
print("You see a signpost ahead.")
time.sleep(2)
print("Do you follow the signpost? (yes/no)")
choice = input().lower()
if choice == "yes":
go_to_lake()
elif choice == "no":
go_to_cave()
else:
print("Invalid choice. Please try again.")
adventure_game()
def go_to_lake():
print("You arrive at a beautiful lake.")
time.sleep(2)
print("You see a boat by the lake.")
time.sleep(2)
print("Do you get on the boat? (yes/no)")
choice = input().lower()
if choice == "yes":
print("You sail across the lake.")
time.sleep(2)
print("You find a treasure chest!")
time.sleep(2)
print("Congratulations! You win!")
elif choice == "no":
print("You decide to explore the lake shore.")
time.sleep(2)
print("While walking, you stumble upon a hidden treasure chest!")
time.sleep(2)
print("Congratulations! You win!")
else:
print("Invalid choice. Please try again.")
go_to_lake()
def go_to_cave():
print("You enter a dark cave.")
time.sleep(2)
print("There are two paths ahead, which do you choose? (left/right)")
choice = input().lower()
if choice == "left":
print("You encounter a ferocious bear!")
time.sleep(2)
print("The bear attacks you. Game over!")
elif choice == "right":
print("You find a hidden chamber with a treasure chest!")
time.sleep(2)
print("Congratulations! You win!")
else:
print("Invalid choice. Please try again.")
go_to_cave()
# Start the game
adventure_game()
```
This code defines a simple adventure game in a mysterious forest. The player is presented with choices and their decisions lead them to different outcomes. The game includes winning scenarios and a losing scenario.
can you give an Text-based Adventure Game! code plz
1 answer