-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmando.py
270 lines (189 loc) · 10.2 KB
/
mando.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
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
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
import os
import random
import time
from colorama import Fore, Back, init
class Mando:
def __init__(self,xcod,ycod):
self.__shape1 = [["|", Fore.YELLOW+'O'+ '\x1b[0m',"|"],[" ", Fore.RED+"\\"+'\x1b[0m', " "],[Fore.YELLOW+"^"+ '\x1b[0m', " ", Fore.YELLOW+"^"+ '\x1b[0m']]
self.__shape2 = [[Back.YELLOW+Fore.WHITE+"|"+'\x1b[0m',Back.YELLOW+Fore.WHITE+ 'O'+'\x1b[0m',Back.YELLOW+Fore.WHITE+ "|"+'\x1b[0m'],[Back.YELLOW+Fore.WHITE+" "+'\x1b[0m', Back.YELLOW+Fore.WHITE+"\\"+'\x1b[0m',Back.YELLOW+Fore.WHITE+ "|"+'\x1b[0m'],[Back.YELLOW+Fore.WHITE+"^"+'\x1b[0m',Back.YELLOW+Fore.WHITE+ "^"+'\x1b[0m',Back.YELLOW+Fore.WHITE+ "|"+'\x1b[0m']]
self.__shape3=[[" "," ",Back.RED+Fore.WHITE+"*"+'\x1b[0m'],[" ",Back.YELLOW+Fore.WHITE+"*"+'\x1b[0m'," "],[Back.YELLOW+Fore.WHITE+"*"+'\x1b[0m'," "," "]]
self.__shape4=[[" ",Back.YELLOW+Fore.WHITE+"*"+'\x1b[0m'," "],[Back.YELLOW+Fore.WHITE+"*"+'\x1b[0m'," ",Back.RED+Fore.WHITE+"*"+'\x1b[0m'],[" "," "," "]]
self.__shape5=[[Back.YELLOW+Fore.WHITE+"*"+'\x1b[0m'," "," "],[" ",Back.YELLOW+Fore.WHITE+"*"+'\x1b[0m'," "],[" "," ",Back.RED+Fore.WHITE+"*"+'\x1b[0m']]
self.__shape6=[[" "," "," "],[Back.YELLOW+Fore.WHITE+"*"+'\x1b[0m'," ",Back.RED+Fore.WHITE+"*"+'\x1b[0m'],[" ",Back.YELLOW+Fore.WHITE+"*"+'\x1b[0m'," "]]
self.__life=5
self.__coin=0
self.__x=xcod
self.__y=ycod
self.__speedboost=0
self.__speedboostime=0
self.__movingfast=0
self.__shield=-1
self.__mydrag=0
self.__shieldtime=round(time.time())
self.__gravmando=round(time.time())
def getMyDrag(self):
return self.__mydrag
def setMyDrag(self,drag):
self.__mydrag=drag
def getMandolife(self):
return self.__life
def setMandolife(self,life):
self.__life=life
def getMandocoin(self):
return self.__coin
def setMandocoin(self,coin):
self.__coin=coin
def getMandocood(self):
return [self.__x, self.__y]
def setMandocood(self,x,y):
self.__x=x
self.__y=y
def getspeedboost(self):
return self.__speedboost
def setspeedboost(self,speedboost):
self.__speedboost=speedboost
def getspeedboostime(self):
return self.__speedboostime
def setspeedboostime(self,speedboostime):
self.__speedboostime=speedboostime
def getshield(self):
return self.__shield
def setshield(self,shield):
self.__shield=shield
def getshieldtime(self):
return self.__shieldtime
def setshieldtime(self,shieldtime):
self.__shieldtime=shieldtime
def getmovingfast(self):
return self.__movingfast
def setmovingfast(self,value):
self.__movingfast=value
def printMando(self,matrix):
self.checkcoins(matrix)
if(self.__shield==0 or self.__shield ==-1 ):
self.checkcol(matrix)
if(self.__mydrag==1):
if(self.__y%4 ==0):
for i in range(self.__x -1, self.__x+2,1):
for j in range(self.__y-1, self.__y+2,1):
matrix[i][j]=self.__shape3[i-self.__x +1][j-self.__y+1]
if(self.__y%4 ==1):
for i in range(self.__x -1, self.__x+2,1):
for j in range(self.__y-1, self.__y+2,1):
matrix[i][j]=self.__shape4[i-self.__x +1][j-self.__y+1]
if(self.__y%4 ==2):
for i in range(self.__x -1, self.__x+2,1):
for j in range(self.__y-1, self.__y+2,1):
matrix[i][j]=self.__shape5[i-self.__x +1][j-self.__y+1]
if(self.__y%4 ==3):
for i in range(self.__x -1, self.__x+2,1):
for j in range(self.__y-1, self.__y+2,1):
matrix[i][j]=self.__shape6[i-self.__x +1][j-self.__y+1]
elif(self.__shield==0 or self.__shield==-1):
for i in range(self.__x -1, self.__x+2,1):
for j in range(self.__y-1, self.__y+2,1):
matrix[i][j]=self.__shape1[i-self.__x +1][j-self.__y+1]
elif(self.__shield ==1):
for i in range(self.__x -1, self.__x+2,1):
for j in range(self.__y-1, self.__y+2,1):
matrix[i][j]=self.__shape2[i-self.__x +1][j-self.__y+1]
def deleteMando(self,matrix):
for i in range(self.__x -1, self.__x+2,1):
for j in range(self.__y-1, self.__y+2,1):
matrix[i][j]=" "
def checkcoins(self, matrix):
x=self.__x
y=self.__y
if(matrix[x][y]==Fore.YELLOW +'$'+ '\x1b[0m'):
self.__coin=self.__coin+1
if(matrix[x][y+1]==Fore.YELLOW +'$'+ '\x1b[0m'):
self.__coin=self.__coin+1
if(matrix[x][y-1]==Fore.YELLOW +'$'+ '\x1b[0m'):
self.__coin=self.__coin+1
if(matrix[x-1][y-1]==Fore.YELLOW +'$'+ '\x1b[0m'):
self.__coin=self.__coin+1
if(matrix[x-1][y]==Fore.YELLOW +'$'+ '\x1b[0m'):
self.__coin=self.__coin+1
if(matrix[x-1][y+1]==Fore.YELLOW +'$'+ '\x1b[0m'):
self.__coin=self.__coin+1
if(matrix[x+1][y+1]==Fore.YELLOW +'$'+ '\x1b[0m'):
self.__coin=self.__coin+1
if(matrix[x+1][y]==Fore.YELLOW +'$'+ '\x1b[0m'):
self.__coin=self.__coin+1
if(matrix[x+1][y-1]==Fore.YELLOW +'$'+ '\x1b[0m'):
self.__coin=self.__coin+1
#for fast moving mando
def activategravity(self):
currtime=round(time.time())
if(currtime-self.__gravmando<=0.4):
self.__x=self.__x + 1
elif(currtime - self.__gravmando <=0.8):
self.__x = self.__x +2
else:
self.__x = self.__x + 3
if(self.__x >=26):
self.__x=26
def deactivategravity(self,time):
self.__gravmando=time
def checkcol(self, matrix):
x=self.__x
y=self.__y
if(self.__mydrag==1):
if(matrix[x][y]==Back.CYAN + Fore.CYAN+'*'+'\x1b[0m' or matrix[x][y]==Back.RED + Fore.WHITE+'*'+'\x1b[0m'):
self.__mydrag=-1
if(matrix[x][y+1]==Back.CYAN + Fore.CYAN+'*'+'\x1b[0m' or matrix[x][y+1]==Back.RED + Fore.WHITE+'*'+'\x1b[0m'):
self.__mydrag=-1
if(matrix[x][y-1]==Back.CYAN + Fore.CYAN+'*'+'\x1b[0m' or matrix[x][y-1]==Back.RED + Fore.WHITE+'*'+'\x1b[0m'):
self.__mydrag=-1
if(matrix[x+1][y]==Back.CYAN + Fore.CYAN+'*'+'\x1b[0m' or matrix[x+1][y]==Back.RED + Fore.WHITE+'*'+'\x1b[0m'):
self.__mydrag=-1
if(matrix[x+1][y+1]==Back.CYAN + Fore.CYAN+'*'+'\x1b[0m' or matrix[x+1][y+1]==Back.RED + Fore.WHITE+'*'+'\x1b[0m'):
self.__mydrag=-1
if(matrix[x+1][y-1]==Back.CYAN + Fore.CYAN+'*'+'\x1b[0m' or matrix[x+1][y-1]==Back.RED + Fore.WHITE+'*'+'\x1b[0m'):
self.__mydrag=-1
if(matrix[x-1][y]==Back.CYAN + Fore.CYAN+'*'+'\x1b[0m' or matrix[x-1][y]==Back.RED + Fore.WHITE+'*'+'\x1b[0m'):
self.__mydrag=-1
if(matrix[x-1][y+1]==Back.CYAN + Fore.CYAN+'*'+'\x1b[0m' or matrix[x-1][y+1]==Back.RED + Fore.WHITE+'*'+'\x1b[0m'):
self.__mydrag=-1
if(matrix[x-1][y-1]==Back.CYAN + Fore.CYAN+'*'+'\x1b[0m' or matrix[x-1][y-1]==Back.RED + Fore.WHITE+'*'+'\x1b[0m'):
self.__mydrag=-1
else:
if(matrix[x][y]==Back.CYAN + Fore.CYAN+'*'+'\x1b[0m' or matrix[x][y]==Back.RED + Fore.WHITE+'*'+'\x1b[0m'):
self.__life=self.__life-1
if(matrix[x][y+1]==Back.CYAN + Fore.CYAN+'*'+'\x1b[0m' or matrix[x][y+1]==Back.RED + Fore.WHITE+'*'+'\x1b[0m'):
self.__life=self.__life-1
if(matrix[x][y-1]==Back.CYAN + Fore.CYAN+'*'+'\x1b[0m' or matrix[x][y-1]==Back.RED + Fore.WHITE+'*'+'\x1b[0m'):
self.__life=self.__life-1
if(matrix[x+1][y]==Back.CYAN + Fore.CYAN+'*'+'\x1b[0m' or matrix[x+1][y]==Back.RED + Fore.WHITE+'*'+'\x1b[0m'):
self.__life=self.__life-1
if(matrix[x+1][y+1]==Back.CYAN + Fore.CYAN+'*'+'\x1b[0m' or matrix[x+1][y+1]==Back.RED + Fore.WHITE+'*'+'\x1b[0m'):
self.__life=self.__life-1
if(matrix[x+1][y-1]==Back.CYAN + Fore.CYAN+'*'+'\x1b[0m' or matrix[x+1][y-1]==Back.RED + Fore.WHITE+'*'+'\x1b[0m'):
self.__life=self.__life-1
if(matrix[x-1][y]==Back.CYAN + Fore.CYAN+'*'+'\x1b[0m' or matrix[x-1][y]==Back.RED + Fore.WHITE+'*'+'\x1b[0m'):
self.__life=self.__life-1
if(matrix[x-1][y+1]==Back.CYAN + Fore.CYAN+'*'+'\x1b[0m' or matrix[x-1][y+1]==Back.RED + Fore.WHITE+'*'+'\x1b[0m'):
self.__life=self.__life-1
if(matrix[x-1][y-1]==Back.CYAN + Fore.CYAN+'*'+'\x1b[0m' or matrix[x-1][y-1]==Back.RED + Fore.WHITE+'*'+'\x1b[0m'):
self.__life=self.__life-1
def checkballcol(self,balls):
x=self.__x
y=self.__y
for i in range(100):
if(balls[i]["enable"]==1):
if((y+1==balls[i]['y'] and x==balls[i]['x']) or (y==balls[i]['y'] and x==balls[i]['x'])):
self.__life=self.__life-1
balls[i]["enable"]=0
if((y+1==balls[i]['y'] and x+1==balls[i]['x']) or (y==balls[i]['y'] and x+1==balls[i]['x'])):
self.__life=self.__life-1
balls[i]["enable"]=0
if((y+1==balls[i]['y'] and x-1==balls[i]['x']) or (y==balls[i]['y'] and x-1==balls[i]['x'])):
self.__life=self.__life-1
balls[i]["enable"]=0
if((y-1==balls[i]['y'] and x+1==balls[i]['x']) or (y==balls[i]['y'] and x+1==balls[i]['x'])):
self.__life=self.__life-1
balls[i]["enable"]=0
if((y-1==balls[i]['y'] and x-1==balls[i]['x']) or (y==balls[i]['y'] and x-1==balls[i]['x'])):
self.__life=self.__life-1
balls[i]["enable"]=0
return balls