comparison pytouhou/game/enemy.py @ 430:c9433188ffdb

Remove AnmWrapper, since ANMs are lists of entries now.
author Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
date Sat, 03 Aug 2013 15:49:04 +0200
parents c689ff1743bf
children 1222341ea22c
comparison
equal deleted inserted replaced
429:40d5f3083ebc 430:c9433188ffdb
22 from math import cos, sin, atan2, pi 22 from math import cos, sin, atan2, pi
23 from pytouhou.game.bullet import LAUNCHED 23 from pytouhou.game.bullet import LAUNCHED
24 24
25 25
26 class Enemy(object): 26 class Enemy(object):
27 def __init__(self, pos, life, _type, bonus_dropped, die_score, anm_wrapper, game): 27 def __init__(self, pos, life, _type, bonus_dropped, die_score, anms, game):
28 self._game = game 28 self._game = game
29 self._anm_wrapper = anm_wrapper 29 self._anms = anms
30 self._type = _type 30 self._type = _type
31 31
32 self.process = None 32 self.process = None
33 self.sprite = None 33 self.sprite = None
34 self.anmrunner = None 34 self.anmrunner = None
219 x, y = pos or (self.x, self.y) 219 x, y = pos or (self.x, self.y)
220 return atan2(player.y - y, player.x - x) 220 return atan2(player.y - y, player.x - x)
221 221
222 222
223 def set_anim(self, index): 223 def set_anim(self, index):
224 entry = 0 if index in self._anms[0].scripts else 1
224 self.sprite = Sprite() 225 self.sprite = Sprite()
225 self.anmrunner = ANMRunner(self._anm_wrapper, index, self.sprite) 226 self.anmrunner = ANMRunner(self._anms[entry], index, self.sprite)
226 self.anmrunner.run_frame() 227 self.anmrunner.run_frame()
227 228
228 229
229 def die_anim(self): 230 def die_anim(self):
230 anim = {0: 3, 1: 4, 2: 5}[self.death_anim % 256] # The TB is wanted, if index isn’t in these values the original game crashs. 231 anim = {0: 3, 1: 4, 2: 5}[self.death_anim % 256] # The TB is wanted, if index isn’t in these values the original game crashs.
239 color += 9 240 color += 9
240 for i in range(number): 241 for i in range(number):
241 self._game.new_particle((self.x, self.y), color, 256) #TODO: find the real size. 242 self._game.new_particle((self.x, self.y), color, 256) #TODO: find the real size.
242 243
243 244
244 def set_aux_anm(self, number, script): 245 def set_aux_anm(self, number, index):
245 self.aux_anm[number] = Effect((self.x, self.y), script, self._anm_wrapper) 246 entry = 0 if index in self._anms[0].scripts else 1
247 self.aux_anm[number] = Effect((self.x, self.y), index, self._anms[entry])
246 248
247 249
248 def set_pos(self, x, y, z): 250 def set_pos(self, x, y, z):
249 self.x, self.y = x, y 251 self.x, self.y = x, y
250 self.update_mode = 1 252 self.update_mode = 1