Mercurial > touhou
comparison pytouhou/game/enemy.py @ 242:1d3c8c7473a2
Implement auxiliary animations of enemies like magic circles, and interruptions from ecl.
author | Emmanuel Gil Peyrot <linkmauve@linkmauve.fr> |
---|---|
date | Mon, 02 Jan 2012 15:46:29 +0100 |
parents | 3cbfa2c11dec |
children | fb3a263213d1 |
comparison
equal
deleted
inserted
replaced
241:dd2bd7283bec | 242:1d3c8c7473a2 |
---|---|
15 | 15 |
16 from pytouhou.utils.interpolator import Interpolator | 16 from pytouhou.utils.interpolator import Interpolator |
17 from pytouhou.vm.anmrunner import ANMRunner | 17 from pytouhou.vm.anmrunner import ANMRunner |
18 from pytouhou.game.sprite import Sprite | 18 from pytouhou.game.sprite import Sprite |
19 from pytouhou.game.bullet import Bullet | 19 from pytouhou.game.bullet import Bullet |
20 from pytouhou.game.effect import Effect | |
20 from math import cos, sin, atan2, pi | 21 from math import cos, sin, atan2, pi |
21 | 22 |
22 | 23 |
23 class Enemy(object): | 24 class Enemy(object): |
24 def __init__(self, pos, life, _type, bonus_dropped, die_score, anm_wrapper, game): | 25 def __init__(self, pos, life, _type, bonus_dropped, die_score, anm_wrapper, game): |
73 | 74 |
74 self.hitbox = (0, 0) | 75 self.hitbox = (0, 0) |
75 self.hitbox_half_size = (0, 0) | 76 self.hitbox_half_size = (0, 0) |
76 self.screen_box = None | 77 self.screen_box = None |
77 | 78 |
79 self.aux_anm = 8 * [None] | |
80 | |
81 | |
82 def objects(self): | |
83 return [anm for anm in self.aux_anm if anm] | |
84 | |
78 | 85 |
79 def set_bullet_attributes(self, type_, anim, sprite_idx_offset, | 86 def set_bullet_attributes(self, type_, anim, sprite_idx_offset, |
80 bullets_per_shot, number_of_shots, speed, speed2, | 87 bullets_per_shot, number_of_shots, speed, speed2, |
81 launch_angle, angle, flags): | 88 launch_angle, angle, flags): |
82 | 89 |
177 if color == 0: | 184 if color == 0: |
178 if self._game.stage in [1, 2, 7]: | 185 if self._game.stage in [1, 2, 7]: |
179 color = 3 | 186 color = 3 |
180 for i in range(number): | 187 for i in range(number): |
181 self._game.new_particle((self.x, self.y), color, 4., 256) #TODO: find the real size. | 188 self._game.new_particle((self.x, self.y), color, 4., 256) #TODO: find the real size. |
189 | |
190 | |
191 def set_aux_anm(self, number, script): | |
192 self.aux_anm[number] = Effect((self.x, self.y), script, self._anm_wrapper) | |
182 | 193 |
183 | 194 |
184 def set_pos(self, x, y, z): | 195 def set_pos(self, x, y, z): |
185 self.x, self.y = x, y | 196 self.x, self.y = x, y |
186 self.interpolator = Interpolator((x, y)) | 197 self.interpolator = Interpolator((x, y)) |
347 | 358 |
348 # Check collisions | 359 # Check collisions |
349 if self.touchable: | 360 if self.touchable: |
350 self.check_collisions() | 361 self.check_collisions() |
351 | 362 |
363 for anm in self.aux_anm: | |
364 if anm: | |
365 anm.x = self.x | |
366 anm.y = self.y | |
367 anm.update() | |
368 | |
352 self.frame += 1 | 369 self.frame += 1 |
353 | 370 |