comparison pytouhou/game/enemymanager.py @ 48:8353c33d53d4

Support a few more instructions
author Thibaut Girka <thib@sitedethib.com>
date Mon, 22 Aug 2011 15:45:42 +0200
parents 25ca15f714ad
children cbe1cb50f2fd
comparison
equal deleted inserted replaced
47:1f1793e7ec8e 48:8353c33d53d4
22 self.max_life = life 22 self.max_life = life
23 self.type = _type 23 self.type = _type
24 self.frame = 0 24 self.frame = 0
25 self.sprite = None 25 self.sprite = None
26 self.pending_bullets = [] 26 self.pending_bullets = []
27 self.bullet_attributes = [] 27 self.bullet_attributes = None
28 self.bullet_launch_offset = (0, 0) 28 self.bullet_launch_offset = (0, 0)
29 self.vulnerable = True
30 self.death_callback = None
31 self.low_life_callback = None
32 self.low_life_trigger = None
33 self.timeout = None
34 self.remaining_lives = -1
35
36 self.bullet_launch_interval = 0
37 self.delay_attack = False
29 38
30 self.death_sprite = None 39 self.death_sprite = None
31 self.movement_dependant_sprites = None 40 self.movement_dependant_sprites = None
32 self.direction = None 41 self.direction = None
33 self.interpolator = None #TODO 42 self.interpolator = None #TODO
36 self.rotation_speed = 0. 45 self.rotation_speed = 0.
37 self.acceleration = 0. 46 self.acceleration = 0.
38 47
39 self.hitbox = (0, 0) 48 self.hitbox = (0, 0)
40 49
41 self.ecl_runner.implementation.update({#67: ('HHIIffffI', self.set_bullet_attributes), 50 self.ecl_runner.implementation.update({67: self.set_bullet_attributes,
42 97: (self.set_sprite), 51 97: self.set_sprite,
43 98: (self.set_multiple_sprites), 52 98: self.set_multiple_sprites,
44 45: (self.set_angle_speed), 53 45: self.set_angle_speed,
45 43: (self.set_pos), 54 43: self.set_pos,
46 46: (self.set_rotation_speed), 55 46: self.set_rotation_speed,
47 47: (self.set_speed), 56 47: self.set_speed,
48 48: (self.set_acceleration), 57 48: self.set_acceleration,
49 51: (self.target_player), 58 51: self.target_player,
50 57: (self.move_to), 59 57: self.move_to,
51 100: (self.set_death_sprite), 60 77: self.set_bullet_interval,
52 103: (self.set_hitbox)}) #TODO 61 78: self.set_delay_attack,
53 62 79: self.set_no_delay_attack,
63 81: self.set_bullet_launch_offset,
64 100: self.set_death_sprite,
65 103: self.set_hitbox,
66 105: self.set_vulnerable,
67 108: self.set_death_callback,
68 113: self.set_low_life_trigger,
69 114: self.set_low_life_callback,
70 115: self.set_timeout,
71 126: self.set_remaining_lives}) #TODO
72
73
74 def set_remaining_lives(self, lives):
75 self.remaining_lives = lives
76
77
78 def set_death_callback(self, sub):
79 self.death_callback = sub
80
81
82 def set_low_life_trigger(self, value):
83 self.low_life_trigger = value
84
85
86 def set_low_life_callback(self, sub):
87 self.low_life_callback = sub
88
89
90 def set_timeout(self, timeout):
91 self.timeout = timeout
92
93
94 def set_vulnerable(self, vulnerable):
95 self.vulnerable = bool(vulnerable & 1)
96
97
98 def set_bullet_launch_offset(self, x, y, z):
99 self.bullet_launch_offset = (x, y)
100
101
102 def set_bullet_attributes(self, bullet_anim, launch_anim, bullets_per_shot,
103 number_of_shots, speed, unknown, launch_angle,
104 angle, flags):
105 self.bullet_attributes = (1, bullet_anim, launch_anim, bullets_per_shot,
106 number_of_shots, speed, unknown, launch_angle,
107 angle, flags)
108 if not self.delay_attack:
109 pass
110 #TODO: actually fire
111
112
113 def set_bullet_interval(self, value):
114 self.bullet_launch_interval = value
115
116
117 def set_delay_attack(self):
118 self.delay_attack = True
119
120
121 def set_no_delay_attack(self):
122 self.delay_attack = False
54 123
55 124
56 def set_death_sprite(self, sprite_index): 125 def set_death_sprite(self, sprite_index):
57 self.death_sprite = sprite_index % 256 #TODO 126 self.death_sprite = sprite_index % 256 #TODO
58 127
92 self.acceleration = acceleration 161 self.acceleration = acceleration
93 162
94 163
95 def target_player(self, unknown, speed): 164 def target_player(self, unknown, speed):
96 self.speed = speed #TODO: unknown 165 self.speed = speed #TODO: unknown
97 player_x, player_y = 192., 400.#TODO 166 player_x, player_y = 192., 384.#TODO
98 self.angle = atan2(player_y - self.y, player_x - self.x) 167 self.angle = atan2(player_y - self.y, player_x - self.x)
99 168
100 169
101 def move_to(self, duration, x, y, z): 170 def move_to(self, duration, x, y, z):
102 self.interpolator.set_interpolation_end(self.frame + duration, (x, y)) 171 self.interpolator.set_interpolation_end(self.frame + duration, (x, y))