Skip to content

Commit a988c45

Browse files
Time Travel Adventure Script Added
1 parent 8c7b746 commit a988c45

File tree

3 files changed

+142
-0
lines changed

3 files changed

+142
-0
lines changed

Time Travel Adventure/README.md

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# Time Travel Adventure Game
2+
3+
## Introduction
4+
5+
Welcome to the Time Travel Adventure! This is an interactive text-based game where the player travels through time, making choices that affect the outcome of the story. The game features multiple time periods to explore, each with its own unique storyline and decisions.
6+
7+
## Features
8+
9+
- Time Travel: Experience different time periods, including the Past, the Future, the Medieval Era, and the Space Age.
10+
- Engaging Storyline: Each time period has its own fascinating storyline with multiple choices to make.
11+
- Inventory System: Collect items during your adventure and use them at specific points in the game.
12+
- Random Events: Encounter unexpected events during time travel that add an element of surprise to the game.
13+
- Health Points: Your choices affect your health points, and if they drop to zero, the game is over.
14+
- Multiple Endings: The outcome of the game depends on the player's decisions, leading to different endings.
15+
16+
## How to Play
17+
18+
1. Make sure you have Python installed on your computer (Python 3.x is recommended).
19+
2. Download the `time_travel_adventure.py` script from this repository.
20+
3. Open a terminal or command prompt in the directory where the script is located.
21+
4. Run the script using the following command:
22+
23+
```bash
24+
python time_travel_adventure.py
25+
```
26+
27+
5. Follow the on-screen instructions to navigate through the game, make choices, and travel through time.
28+
29+
## Gameplay Tips
30+
31+
- Pay attention to the storyline and choose wisely, as your decisions can have lasting consequences.
32+
- Keep an eye on your health points and collect items to help you in your journey.
33+
- Be prepared for random events during time travel, they may alter your path!
34+
35+
## Acknowledgments
36+
37+
The Time Travel Adventure game was inspired by various text-based adventure games and interactive storytelling experiences.
38+
39+
Feel free to modify and expand the game according to your creative ideas. Happy time traveling and enjoy the adventure!
40+
41+
If you encounter any issues or have suggestions, please feel free to create an issue or submit a pull request.
42+
43+
Thank you for playing!
44+
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
random
Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
import time
2+
import random
3+
4+
def print_slow(text):
5+
for char in text:
6+
print(char, end='', flush=True)
7+
time.sleep(0.05)
8+
print()
9+
10+
def get_choice(prompt, options):
11+
while True:
12+
print(prompt)
13+
for i, option in enumerate(options, 1):
14+
print(f"{i}. {option}")
15+
try:
16+
choice = int(input("Enter your choice (1-{}): ".format(len(options))))
17+
if 1 <= choice <= len(options):
18+
return choice
19+
else:
20+
print("Invalid input. Please choose a valid option.")
21+
except ValueError:
22+
print("Invalid input. Please enter a number.")
23+
24+
def time_travel_adventure():
25+
print_slow("Welcome to the Time Travel Adventure!\n")
26+
print_slow("You find a mysterious time machine and decide to give it a try.")
27+
28+
inventory = []
29+
health_points = 100
30+
31+
# Starting point - Present
32+
print_slow("\nYou are in the present time.")
33+
choice = get_choice("Where would you like to travel?", ["Go to the past", "Go to the future", "Go to the Medieval Era", "Go to the Space Age"])
34+
35+
if choice == 1:
36+
print_slow("\nYou traveled to the past.")
37+
# Past storyline and choices here
38+
print_slow("You encountered dinosaurs in the past.")
39+
choice = get_choice("What do you do?", ["Try to befriend them", "Run away"])
40+
if choice == 1:
41+
print_slow("You manage to befriend a baby dinosaur. It's a heartwarming moment!")
42+
inventory.append("Dinosaur Egg")
43+
else:
44+
print_slow("You ran away from the dinosaurs and found yourself back in the present.")
45+
elif choice == 2:
46+
print_slow("\nYou traveled to the future.")
47+
# Future storyline and choices here
48+
print_slow("You arrived in a futuristic city.")
49+
choice = get_choice("What do you do?", ["Explore the city", "Seek help from locals"])
50+
if choice == 1:
51+
print_slow("You explored the city and had a fascinating experience in the future.")
52+
health_points -= 20
53+
else:
54+
print_slow("The locals are friendly and offer you a tour of their advanced technology.")
55+
inventory.append("Futuristic Device")
56+
elif choice == 3:
57+
print_slow("\nYou traveled to the Medieval Era.")
58+
# Medieval storyline and choices here
59+
print_slow("You find yourself in a medieval kingdom.")
60+
choice = get_choice("What do you do?", ["Attend a royal feast", "Help a poor villager"])
61+
if choice == 1:
62+
print_slow("You attended a grand feast at the castle. The king was impressed by your presence.")
63+
inventory.append("Royal Medal")
64+
else:
65+
print_slow("You helped the villager, who turned out to be a powerful sorcerer. He grants you a magical amulet.")
66+
inventory.append("Amulet of Power")
67+
else:
68+
print_slow("\nYou traveled to the Space Age.")
69+
# Space Age storyline and choices here
70+
print_slow("You are on a space station orbiting a distant planet.")
71+
choice = get_choice("What do you do?", ["Investigate the planet", "Repair the space station"])
72+
if choice == 1:
73+
print_slow("You embarked on a planetary exploration mission and made significant scientific discoveries.")
74+
inventory.append("Alien Artifact")
75+
else:
76+
print_slow("You successfully repaired the space station and gained the respect of the space crew.")
77+
inventory.append("Space Suit")
78+
79+
if health_points <= 0:
80+
print_slow("\nYour health is too low to continue the journey. Game Over!")
81+
else:
82+
# Random event during time travel
83+
if random.random() < 0.3:
84+
print_slow("\nDuring your time travel, you encounter a time vortex!")
85+
print_slow("You got disoriented but managed to find your way back.")
86+
health_points -= 10
87+
88+
print_slow("\nYou are back in the present time.")
89+
choice = get_choice("What would you like to do?", ["End the game", "Continue the adventure"])
90+
if choice == 1:
91+
print_slow("\nThanks for playing the Time Travel Adventure!")
92+
else:
93+
print_slow("You decide to embark on another time travel adventure!")
94+
time_travel_adventure()
95+
96+
if __name__ == "__main__":
97+
time_travel_adventure()

0 commit comments

Comments
 (0)