comparison pytouhou/game/enemy.py @ 173:35d850502d1f

Move effects where they should be.
author Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
date Fri, 21 Oct 2011 09:37:23 -0700
parents 2f3665a77f11
children 6e8653ff2b23
comparison
equal deleted inserted replaced
172:ea2ad94c33a0 173:35d850502d1f
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.item import Item 20 from pytouhou.game.item import Item
21 from math import cos, sin, atan2, pi 21 from math import cos, sin, atan2, pi
22
23
24 class Effect(object):
25 def __init__(self, pos, index, anm_wrapper):
26 self._sprite = Sprite()
27 self._anmrunner = ANMRunner(anm_wrapper, index, self._sprite)
28 self._anmrunner.run_frame()
29 self._removed = False
30
31 self.x, self.y = pos
32
33 def update(self):
34 if self._anmrunner and not self._anmrunner.run_frame():
35 self._anmrunner = None
36
37 if self._sprite:
38 if self._sprite._removed:
39 self._sprite = None
40 22
41 23
42 class Enemy(object): 24 class Enemy(object):
43 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):
44 self._game = game 26 self._game = game
171 def on_collide(self): 153 def on_collide(self):
172 self.life -= 80 # found experimentally 154 self.life -= 80 # found experimentally
173 155
174 156
175 def die_anim(self): 157 def die_anim(self):
176 eff00 = self._game.resource_loader.get_anm_wrapper(('eff00.anm',)) 158 self._game.new_effect((self.x, self.y), self.death_anim)
177 self._game.effects.append(Effect((self.x, self.y), self.death_anim, eff00))
178 159
179 160
180 def set_pos(self, x, y, z): 161 def set_pos(self, x, y, z):
181 self.x, self.y = x, y 162 self.x, self.y = x, y
182 self.interpolator = Interpolator((x, y)) 163 self.interpolator = Interpolator((x, y))