-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCar game.py
More file actions
236 lines (232 loc) · 8.32 KB
/
Car game.py
File metadata and controls
236 lines (232 loc) · 8.32 KB
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
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
import random
name_right = False
while name_right == False:
name = input('What is your name(3-15)? ')
name_number = len(name)
if name_number < 3:
print('name is too short just like your....')
elif name_number > 15:
print('one long name you have shorten it down')
else:
name_right = True
print('say -----> help')
in_car = True
in_jail = False
started = False
stopped = True
driving = False
object_middle = False
object_left = False
object_right = False
object_back = False
object_human = False
while in_car == True:
car_command = input('> ')
if car_command == 'start':
if started == True:
print(f'Car is already started {name}')
stopped = False
elif started == False:
print(f'{name} starts the car')
started = True
elif car_command == 'stop':
if stopped == True:
print(f'Car is already started {name}')
started = False
driving = False
elif stopped == False:
print(f'{name} stops the car')
stopped = True
elif car_command == 'help':
print("""
Commands-
start
stop
quit
drive
""")
elif car_command == 'drive':
if started == True:
print(f'{name} starts driving')
driving = True
print('say help to start drive around')
else:
print('start your car ' + name)
elif car_command == 'quit':
print("nooo don't leave " + name)
break
while driving == True:
car_direction = input('> ')
if car_direction == 'help':
print("""
Forward(f)
Left(l)
Right(r)
Brake(s)
Backup(b)
quit(q)
""")
elif car_direction == 'f':
random_f = random.randint(1, 4)
if random_f == 1:
if object_middle == True:
print('crash')
elif object_human == True:
in_car = False
driving = False
in_jail = True
elif object_middle == False:
print('the road end in 200ft choose left or right')
object_middle = True
object_left = False
object_right = False
object_human = False
if random_f == 2:
if object_middle == True:
print('crash')
elif object_human == True:
in_car = False
driving = False
in_jail = True
elif object_middle == False:
print('There is a Tree to your Left')
object_middle = False
object_left = True
object_right = False
object_human = False
if random_f == 3:
if object_middle == True:
print('crash')
elif object_human == True:
in_car = False
driving = False
in_jail = True
elif object_middle == False:
print('There is a truck to your right')
object_middle = False
object_left = False
object_right = True
object_human = False
if random_f == 4:
if object_middle == True:
print('crash')
elif object_human == True:
in_car = False
driving = False
in_jail = True
object_human = False
elif object_middle == False:
print('WATCH OUT THERE IS A FAMILY OF 4 IN FRONT OF YOU')
object_middle = False
object_left = False
object_right = False
object_human = True
elif car_direction == 'l':
random_l = random.randint(1, 4)
if random_l == 1:
if object_left == True:
print('crash')
elif object_left == False:
print('the road end in 200ft choose left or right')
object_middle = True
object_left = False
object_right = False
object_human = False
if random_l == 2:
if object_left == True:
print('crash')
elif object_left == False:
print('There is a Tree to your Left')
object_middle = False
object_left = True
object_right = False
object_human = False
if random_l == 3:
if object_left == True:
print('crash')
elif object_left == False:
print('There is a truck to your right')
object_middle = False
object_left = False
object_right = True
object_human = False
if random_l == 4:
if object_left == True:
print('crash')
elif object_left == False:
print('WATCH OUT THERE IS A FAMILY OF 4 IN FRONT OF YOU')
object_middle = False
object_left = False
object_right = False
object_human = True
elif car_direction == 'r':
random_r = random.randint(1, 4)
if random_r == 1:
if object_right == True:
print('crash')
elif object_right == False:
print('the road end in 200ft choose left or right')
object_middle = True
object_left = False
object_right = False
object_human = False
if random_r == 2:
if object_right == True:
print('crash')
elif object_right == False:
print('There is a Tree to your Left')
object_middle = False
object_left = True
object_right = False
object_human = False
if random_r == 3:
if object_right == True:
print('crash')
elif object_right == False:
print('There is a truck to your right')
object_middle = False
object_left = False
object_right = True
object_human = False
if random_r == 4:
if object_right == True:
print('crash')
elif object_right == False:
print('WATCH OUT THERE IS A FAMILY OF 4 IN FRONT OF YOU')
object_middle = False
object_left = False
object_right = False
object_human = True
elif car_direction == 'b':
random_b = random.randint(1, 3)
if random_b == 1:
if object_back == True:
print('crash')
elif object_back == False:
print('the road end in 200ft choose left or right')
object_middle = True
object_left = False
object_right = False
object_human = False
if random_b == 2:
if object_back == True:
print('crash')
elif object_back == False:
print('There is a Tree to your Left')
object_middle = False
object_left = True
object_right = False
object_human = False
if random_b == 3:
if object_back == True:
print('crash')
elif object_back == False:
print('There is a truck to your right')
object_middle = False
object_left = False
object_right = True
object_human = False
elif car_direction == 'q':
print('You can never leave!')
while in_jail == True:
print(f"{name} You Are Sick ")