-
Notifications
You must be signed in to change notification settings - Fork 0
/
heat_box.py
61 lines (49 loc) · 1.78 KB
/
heat_box.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
from pico2d import *
import game_framework
import game_world
import main_state
def collide(a, b):
left_a, bottom_a, right_a, top_a = a.get_bb()
left_b, bottom_b, right_b, top_b = b.get_bb()
if left_a > right_b: return False
if right_a < left_b: return False
if top_a < bottom_b: return False
if bottom_a > top_b: return False
return True
class Heat_box:
def __init__(self, bg):
self.bg = bg
self.boy = main_state.get_boy()
self.x, self.y = self.boy.x + 30, self.boy.y
self.attack_time = 1
self.isFire = False
self.timer = 0.001
def draw(self):
pass
def update(self):
Monster_Bear_List = main_state.get_Monster_Bear_List()
Monster_Mage_List = main_state.get_Monster_Mage_List()
self.attack_time -= 1
self.attack_time = clamp(0, self.attack_time, 1)
if self.attack_time == 0:
pass
else:
self.attack_time = 1
for i in range(len(Monster_Bear_List)):
if collide(self, Monster_Bear_List[i]):
game_world.remove_object(self)
Monster_Bear_List[i].damaged(self.boy.STR, self.isFire)
for i in range(len(Monster_Mage_List)):
if collide(self, Monster_Mage_List[i]):
game_world.remove_object(self)
Monster_Mage_List[i].damaged(self.boy.STR, self.isFire)
self.timer -= game_framework.frame_time
if self.timer < 0:
self.timer += 0.001
game_world.remove_object(self)
def get_bb(self):
cx, cy = self.x - self.bg.window_left, self.y - self.bg.window_bottom
if self.boy.dir == 1:
return cx + 30, cy - 30, cx + 50, cy + 30
else:
return cx - 80, cy - 30, cx - 60, cy + 30