-
Notifications
You must be signed in to change notification settings - Fork 0
/
inimigo.py
123 lines (113 loc) · 4.72 KB
/
inimigo.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
import constanteMapa
class Inimigo:
def __init__(self, nome,x,y,depth,sentido = 0):
self.id = nome
self.x = x
self.y = y
self.XMin = x - depth
self.YMin = y - depth
self.XMax = x + depth
self.YMax = y + depth
self.sentido = sentido
def step(self,mapa):
mapa[self.x][self.y] = 2
if(self.id == 'v'):
if(self.sentido == 0):
if(self.YMax == self.y or mapa[self.x][self.y + 1] <= constanteMapa.PAREDE ):
# print('mudou e sub')
self.sentido = 1
if(self.y - 1 > self.YMin):
self.y -= 1
else:
# print('add')
self.y += 1
else:
if(self.YMin == self.y or mapa[self.x][self.y - 1] <= constanteMapa.PAREDE):
# print('mudou e add')
self.sentido = 0
if(self.y + 1 < self.YMax):
self.y += 1
else:
# print('sub')
self.y -= 1
if(self.sentido == 0 ):
mapa[self.x][self.y] = constanteMapa.INIMIGOV
else:
mapa[self.x][self.y] = constanteMapa.INIMIGOVV
if(self.id == 'h'):
if(self.sentido == 0):
if(self.XMax == self.x or mapa[self.x + 1][self.y] <= constanteMapa.PAREDE):
# print('mudou e sub')
self.sentido = 1
if(self.x - 1 > self.XMin):
self.x -= 1
else:
# print('add')
self.x += 1
else:
if(self.XMin == self.x or mapa[self.x -1][self.y] <= constanteMapa.PAREDE):
# print('mudou e add')
self.sentido = 0
if(self.x + 1 < self.XMax):
self.x += 1
else:
# print('sub')
self.x -= 1
if(self.sentido == 0 ):
mapa[self.x][self.y] = constanteMapa.INIMIGOH
else:
mapa[self.x][self.y] = constanteMapa.INIMIGOHH
if(self.id == 'd1'):
if(self.sentido == 0):
if(self.XMax == self.x or mapa[self.x + 1][self.y + 1] <= constanteMapa.PAREDE):
# print('mudou e sub')
self.sentido = 1
if(self.x - 1 > self.XMin and self.y - 1 > self.YMin):
self.x -= 1
self.y -= 1
else:
# print('add')
self.x += 1
self.y += 1
else:
if(self.XMin == self.x or mapa[self.x -1][self.y-1] <= constanteMapa.PAREDE):
# print('mudou e add')
self.sentido = 0
if(self.x + 1 < self.XMax and self.y + 1 < self.YMax):
self.x += 1
self.y += 1
else:
# print('sub')
self.x -= 1
self.y -= 1
if(self.sentido == 0 ):
mapa[self.x][self.y] = constanteMapa.INIMIGOD1
else:
mapa[self.x][self.y] = constanteMapa.INIMIGOD11
if(self.id == 'd2'):
if(self.sentido == 0):
if(self.XMin == self.x or mapa[self.x - 1][self.y + 1] <= constanteMapa.PAREDE):
# print('mudou e sub')
self.sentido = 1
if(self.x + 1 < self.XMax and self.y - 1 > self.YMin and mapa[self.x + 1][self.y-1] > constanteMapa.PAREDE):
self.x += 1
self.y -= 1
else:
# print('add')
self.x -= 1
self.y += 1
else:
if(self.XMax == self.x or mapa[self.x +1][self.y-1] <= constanteMapa.PAREDE):
# print('mudou e add')
self.sentido = 0
if(self.x - 1 > self.XMin and self.y + 1 < self.YMax and mapa[self.x - 1][self.y+1] > constanteMapa.PAREDE):
self.x -= 1
self.y += 1
else:
# print('sub')
self.x += 1
self.y -= 1
if(self.sentido == 0 ):
mapa[self.x][self.y] = constanteMapa.INIMIGOD1
else:
mapa[self.x][self.y] = constanteMapa.INIMIGOD11