-
Notifications
You must be signed in to change notification settings - Fork 89
/
Copy pathAdventure-game.py
174 lines (169 loc) · 6.67 KB
/
Adventure-game.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
166
167
168
169
170
171
172
173
174
import time
import sys
answer_left=["left","Left","LEFT"]
answer_right=["right","Right","RIGHT"]
answer_forward=["forward","Forward","FORWARD"]
answer_backward=["backward","Backward","BACKWARD"]
#Correct Answer : Right -> Left -> Forward -> Right
def intro():
print("You are in ROOM 1 now.")
print("What do you see in Room 1?")
room1= input(" ")
print("Alright, You are in Room1 and you saw ",room1)
print("Enter the direction in which you want to continue :")
print("Left,Right,Forward")
time.sleep(1)
choice = input (">>>")
direction1=choice
while (choice):
if choice in answer_left or choice in answer_forward:
direction1=choice
print("You are in Room 1 and now you want to move ",direction1)
print("Walls present, can't move further in this direction ")
print("Re enter choice")
print("Left,Right,Forward")
time.sleep(1)
choice = input (">>>")
elif choice in answer_right:
direction1=choice
print("------------------------------------------------------------------------------------------------------")
print("Doors found. You opened the door and moved into ROOM 2")
print("So after starting the game in ROOM 1, you moved ",direction1," to go to room 2.")
print("What do you see in Room 2?")
room2= input(" ")
print("Alright, You are in Room2 and you saw ",room2)
print("Enter direction you want to continue")
print("Left,Right,Forward,Backward")
time.sleep(1)
choice = input (">>>")
direction2=choice
while (choice):
if choice in answer_right or choice in answer_forward :
direction2=choice
print("After starting in Room 1 you moved ",direction1," to go to room 2. Now you want to move ")
print(direction2," to go to Room 3")
print("Walls present, can't move further in this direction ")
print("Re enter choice")
print("Left,Right,Forward,Backward")
time.sleep(1)
choice = input (">>>")
elif choice in answer_backward:
direction2=choice
print("Oops we went back to Room 1 again by moving ",direction2,". Lets go back and try again.")
print("Re enter choice")
print("Left,Right,Forward,Backward")
time.sleep(1)
choice = input (">>>")
elif choice in answer_left:
direction2=choice
print("------------------------------------------------------------------------------------------------------")
print("Doors found. You opened the door and moved into ROOM 3")
print("So after starting the game in ROOM 1, you moved ",direction1," to go to room 2 and then you moved .")
print(direction2," to go to Room 3.")
print("What do you see in Room 3?")
room3= input(" ")
print("Alright, You are in Room3 and you saw ",room3)
print("Enter direction you want to continue")
print("Left,Right,Forward,Backward")
time.sleep(1)
choice = input (">>>")
direction3=choice
while (choice):
direction3=choice
if choice in answer_left or choice in answer_right:
direction3=choice
print("After starting in room 1 you moved ",direction1," to go to room 2.")
print("Then you moved ",direction2," to go to Room 3. Now you want to move ",direction3)
print("Walls present, can't move further in this direction ")
print("Re enter choice")
print("Left,Right,Forward,Backward")
time.sleep(1)
choice = input (">>>")
elif choice in answer_backward:
direction3=choice
print("Oops we went back to Room 2 again by moving ",direction3," Lets go back and try again.")
print("Re enter choice")
print("Left,Right,Forward,Backward")
time.sleep(1)
choice = input (">>>")
elif choice in answer_forward:
direction3=choice
print("------------------------------------------------------------------------------------------------------")
print("Doors found. You opened the door and moved into ROOM 4")
print("So after starting the game in ROOM 1, you moved ",direction1," to go to room 2 and then you moved ")
print(direction2," to go to Room 3 and then you moved ",direction3," to go to Room 4")
print("What do you see?")
room4= input(" ")
print("Alright, You are in Room4 and you saw ",room4)
print("Enter direction you want to continue")
print("1. Enter 1 to go left")
print("2. Enter 2 to go right")
print("3. Enter 3 to move forward")
print("4. Enter 4 to move backwards")
time.sleep(1)
choice = input (">>>")
direction4=choice
while (choice != "2"):
if choice =="1" or choice == "3":
direction4=choice
print("So after starting the game in ROOM 1, you moved ",direction1," to go to room 2 and then you moved ")
print(direction2," to go to Room 3 and then you moved ",direction3," to go to Room 4. Now you want to move ")
print(direction4," to go out of the house. ")
print("Walls present, can't move further in this direction ")
print("Re enter choice")
print("1. Enter 1 to go left")
print("2. Enter 2 to go right")
print("3. Enter 3 to move forward")
print("4. Enter 4 to move backwards")
time.sleep(1)
choice = input (">>>")
elif choice =="4":
direction4=choice
print("Oops we went back to Room 3 again by moving ",direction4,".Lets go back and try again.")
print("Re enter choice")
print("1. Enter 1 to go left")
print("2. Enter 2 to go right")
print("3. Enter 3 to move forward")
print("4. Enter 4 to move backwards")
time.sleep(1)
choice = input (">>>")
else:
print("Wrong Choice. Please re enter.")
print("1. Enter 1 to go left")
print("2. Enter 2 to go right")
print("3. Enter 3 to move forward")
print("4. Enter 4 to move backwards")
time.sleep(1)
choice = input (">>>")
direction4=choice
if choice == "2":
direction4=choice
print("------------------------------------------------------------------------------------------------------")
print("Congratulations! You reached the exit.")
print("After starting the game in ROOM 1, you moved ",direction1," to go to ROOM 2, then moved ",direction2)
print(" to go to ROOM 3, then moved ",direction3," to go to ROOM 4 and finally moved right to go outside the house.")
print("You saw ",room1," in Room 1")
print("You saw ",room2," in Room 2")
print("You saw ",room3," in Room 3")
print("You saw ",room4," in Room 4")
print("GAME OVER.")
sys.exit()
else:
print("Wrong choice. Please re enter.")
print("Left,Right,Forward,Backward")
time.sleep(1)
choice = input (">>>")
direction3= choice
else:
print("Wrong choice. Please re enter.")
print("Left,Right,Forward,Backward")
time.sleep(1)
choice = input (">>>")
direction2=choice
else:
print("Wrong choice. Please re enter.")
print("Left,Right,Forward")
time.sleep(1)
choice = input (">>>")
direction2=choice
intro()