-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathGame.py
More file actions
211 lines (196 loc) · 5.62 KB
/
Game.py
File metadata and controls
211 lines (196 loc) · 5.62 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
#allows us to clear screen
from os import system, name
#use rand for sudo random number
import random as rand
#to move around
from getch import getch
def SC():
if name == 'nt':
_ = system('cls')
else:
_ = system('clear')
def flat(floor, direction):
if direction == False:
for i in range (hei):
D2ZONE[i].pop()
if i < floor:
x = rand.randint(1, 75)
if x != 1:
D2ZONE[i].insert(0, '*')
elif x == 1:
D2ZONE[i].insert(0, '-')
elif i == floor:
D2ZONE[i].insert(0, '_')
else:
x = rand.randint(1, 75)
if x != 1:
D2ZONE[i].insert(0, '#')
elif x == 1:
D2ZONE[i].insert(0, '%')
else:
for i in range (hei):
D2ZONE[i].pop(0)
if i < floor:
x = rand.randint(1, 75)
if x != 1:
D2ZONE[i].append('*')
elif x == 1:
D2ZONE[i].append('-')
elif i == floor:
D2ZONE[i].append('_')
else:
x = rand.randint(1, 75)
if x != 1:
D2ZONE[i].append('#')
elif x == 1:
D2ZONE[i].append('%')
def layprint():
for i in range (hei):
print(''.join(D2ZONE[i]))
def noise(start, direction):
start = int(start)
direction = bool(direction)
way = rand.randint(1,5)
#going down so start go up
if way == 1:
if start + 1 < hei - 1 and start + 2 < hei - 1:
start += 1
if direction == False:
for i in range (hei):
D2ZONE[i].pop()
if i < start:
x = rand.randint(1, 75)
if x != 1:
D2ZONE[i].insert(0, '*')
elif x == 1:
D2ZONE[i].insert(0, '-')
elif i == start:
D2ZONE[i].insert(0, '/')
else:
x = rand.randint(1, 75)
if x != 1:
D2ZONE[i].insert(0, '#')
elif x == 1:
D2ZONE[i].insert(0, '%')
elif direction == True:
for i in range (hei):
D2ZONE[i].pop(0)
if i < start:
x = rand.randint(1, 75)
if x != 1:
D2ZONE[i].append('*')
elif x == 1:
D2ZONE[i].append('-')
elif i == start:
D2ZONE[i].append('\ '.strip())
else:
x = rand.randint(1, 75)
if x != 1:
D2ZONE[i].append('#')
elif x == 1:
D2ZONE[i].append('%')
return 1
else:
flat(start, direction)
return 0
elif way == 3:
#floor goes up so start go down
if start - 1 > 0 and start - 2 > 0:
if direction == False:
for i in range (hei):
D2ZONE[i].pop()
if i < start:
D2ZONE[i].insert(0, '*')
elif i == start:
D2ZONE[i].insert(0, '\ '.strip())
else:
x = rand.randint(1, 75)
if x != 1:
D2ZONE[i].insert(0, '#')
elif x == 1:
D2ZONE[i].insert(0, '%')
elif direction == True:
for i in range (hei):
D2ZONE[i].pop(0)
if i < start:
x = rand.randint(1, 75)
if x != 1:
D2ZONE[i].append('*')
elif x == 1:
D2ZONE[i].append('-')
elif i == start:
D2ZONE[i].append('/')
else:
x = rand.randint(1, 75)
if x != 1:
D2ZONE[i].append('#')
elif x == 1:
D2ZONE[i].append('%')
start -= 1
return -1
else:
flat(start, direction)
return 0
#floor stays the same
else:
flat(start, direction)
return 0
wid = 50
hei = 15
#set the original layout
D2ZONE = []
for i in range (hei):
D2ZONE.append(['*'] * wid)
SC()
layprint()
SC()
x = int(13)
for i in range (wid):
x = x + noise(x, False)
layprint()
save = None
saveint = None
jump = False
while True:
key = getch()
if key != None:
if key == 'a':
for i in range (hei):
if D2ZONE[i][0] == '_':
noise(i, False)
break
elif D2ZONE[i][0] == '/':
noise(i, False)
break
elif D2ZONE[i][0] == '\ '.strip():
noise(i - 1, False)
break
elif key == 'd':
for i in range (hei):
if D2ZONE[i][wid - 1] == '_':
noise(i, True)
break
elif D2ZONE[i][wid - 1] == '\ '.strip():
noise(i, True)
break
elif D2ZONE[i][wid - 1] == '/':
noise(i - 1, True)
break
elif key == ' ':
jump = True
for i in range (hei):
if D2ZONE[i][25] == '_' or D2ZONE[i][25] == '/' or D2ZONE[i][25] == '@' or D2ZONE[i][25] == '\ '.strip():
if jump == False:
save = D2ZONE[i][25]
saveint = i
else:
save = D2ZONE[i - 1][25]
saveint = i - 1
if jump == False:
D2ZONE[i][25] = '@'
else:
D2ZONE[i-1][25] = '@'
jump = False
SC()
layprint()
D2ZONE[saveint][25] = save