-
Notifications
You must be signed in to change notification settings - Fork 23
/
Copy pathbomb.py
57 lines (50 loc) · 2.14 KB
/
bomb.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
class Bomb:
frame = 0
def __init__(self, r, x, y, map, bomber):
self.range = r
self.pos_x = x
self.pos_y = y
self.time = 3000
self.bomber = bomber
self.sectors = []
self.get_range(map)
def update(self, dt):
self.time = self.time - dt
if self.time < 1000:
self.frame = 2
elif self.time < 2000:
self.frame = 1
def get_range(self, map):
self.sectors.append([self.pos_x, self.pos_y])
for x in range(1, self.range):
if map[self.pos_x + x][self.pos_y] == 1:
break
elif map[self.pos_x + x][self.pos_y] == 0 or map[self.pos_x - x][self.pos_y] == 3:
self.sectors.append([self.pos_x + x, self.pos_y])
elif map[self.pos_x + x][self.pos_y] == 2:
self.sectors.append([self.pos_x + x, self.pos_y])
break
for x in range(1, self.range):
if map[self.pos_x - x][self.pos_y] == 1:
break
elif map[self.pos_x - x][self.pos_y] == 0 or map[self.pos_x - x][self.pos_y] == 3:
self.sectors.append([self.pos_x - x, self.pos_y])
elif map[self.pos_x - x][self.pos_y] == 2:
self.sectors.append([self.pos_x - x, self.pos_y])
break
for x in range(1, self.range):
if map[self.pos_x][self.pos_y + x] == 1:
break
elif map[self.pos_x][self.pos_y + x] == 0 or map[self.pos_x][self.pos_y + x] == 3:
self.sectors.append([self.pos_x, self.pos_y + x])
elif map[self.pos_x][self.pos_y + x] == 2:
self.sectors.append([self.pos_x, self.pos_y + x])
break
for x in range(1, self.range):
if map[self.pos_x][self.pos_y - x] == 1:
break
elif map[self.pos_x][self.pos_y - x] == 0 or map[self.pos_x][self.pos_y - x] == 3:
self.sectors.append([self.pos_x, self.pos_y - x])
elif map[self.pos_x][self.pos_y - x] == 2:
self.sectors.append([self.pos_x, self.pos_y - x])
break