-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
165 lines (138 loc) · 4.27 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
import sys
import time
# main game variables
gCurrentScene = 1
gJustEnteredScene = True
gMain = True
gSceneMissleDoorOpen = [False]
# default player powerups
pBeams = ["power"]
# missle values
pHasMissles = False # they don't at the start
pMisslesUpgrades = 1
pMisslesMax = 5*pMisslesUpgrades
pMissles = 5
"""
pGetInput:
Main input routine
"""
def pGetInput() :
global pInput # needs to be glabal to be easy to manage
pInputBreak = True
while pInputBreak :
pInput = input("> ").lower()
if pInput == "stats" :
print("Your Beams:")
for x in pBeams :
print("-", x.title())
# only display missles if the player has them
if pHasMissles :
print("Missles:", pMissles)
elif pInput == "exit" :
print("See you next mission!")
sys.exit()
else :
# normal action input
try :
pInput = int(pInput)
except :
print("Unknown input. Try again.")
continue
else :
print("\n------------------------------------------------------------")
return pInput
"""
Main loop
"""
# intro text
text = """
Welcome to Metroid: The Text Adventure Game!
You are the interstellar bounty hunter Samus Aran, who has
been sent by the Galactic Federation to investigate planet
Axius 77. They've found a presence of Space Pirate activity
and they're suspicious of their behaviour. They've noted
that an unknown powerful species lurks on the planet,
however, their scans and research could not determine what
it could be, or what threat it could pose to you. They
advise you to be careful, and tread lightly.
"""
# kinda hacky but idk
# this prints the intro text character by character
for char in text :
sys.stdout.write(char)
sys.stdout.flush()
time.sleep(.05)
if "\n" in char :
time.sleep(1)
time.sleep(2)
input("\nPress enter to continue. ")
print("------------------------------------------------------------")
while True :
# scene 1
if gCurrentScene == 1:
if gJustEnteredScene == True :
print("""
You've landed your ship in a crater on Axius 77. The purple
grass and blue sky don't feel so inviting. In the crater,
there's two hexagonal doors to your left and right.
""")
# text to show if the player hasn't unlocked the door
if gSceneMissleDoorOpen[0] == False :
print("The door on your left is locked.")
gJustEnteredScene = False
# player choices
print("\nYour choices are:")
print("1: Enter the door on your right.")
if gSceneMissleDoorOpen[0] == False :
print("2: Try the door on your left.")
else :
print("2: Enter the door on your left.")
# scene specific inputs
match pGetInput() :
case 1 :
gJustEnteredScene = True
gCurrentScene = 2
case 2 :
if pHasMissles == True and pMissles > 0 :
if gSceneMissleDoorOpen[0] == False :
gSceneMissleDoorOpen[0] = True
pMissles -= 1
print("You unlocked the door by firing a missle at it.")
print("You now have", pMissles, "missles left.")
gJustEnteredScene = True
gCurrentScene = 3
elif pMissles == 0 : # can't open the door if the player doesn't have missles
print("\nYou do not have any missles to open the door.")
else :
print("\nYou can't seem to open this door. An explosive weapon could\nopen the door.\n")
case _ :
print("Invalid input. Try again.")
if gCurrentScene == 2 :
if gJustEnteredScene == True :
if pHasMissles == False :
print("""
You take the door to your right. Among the clean blue
metalic dome interior, a Missle Launcher attachment is in
the center of the room. You take it and apply it to your
arm cannon.
You unlocked the Missle Launcher! Among being strong to
enemies, it may also unlock certain doors!""")
pHasMissles = True # player obtains the missle launcher
else :
print("""
You take the door to your right. This is the room where you
obtained the Missle Launcher attachment. The room is small,
and is covered in a clean, blue metalic surface.""")
# player choices
print("\nYour choices are:")
print("1: Leave the room.")
# scene specific inputs
match pGetInput() :
case 1 :
gJustEnteredScene = True
gCurrentScene = 1
case _ :
print("Invalid input. Try again.")
if gCurrentScene == 3 :
print("\n\n\nThis is it of the small demo.\nI could easily expand on it if I want to but this is just a rough base.\nThanks for playing!")
sys.exit()