Mercurial > touhou
changeset 107:5d9052b9a4e8
(almost) implement Cirno's freezing spellcard
author | Thibaut Girka <thib@sitedethib.com> |
---|---|
date | Mon, 05 Sep 2011 23:04:43 +0200 |
parents | c7847bfed427 |
children | 2a03940deea3 |
files | pytouhou/formats/ecl.py pytouhou/game/bullet.py pytouhou/vm/eclrunner.py |
diffstat | 3 files changed, 31 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/pytouhou/formats/ecl.py +++ b/pytouhou/formats/ecl.py @@ -117,7 +117,7 @@ class ECL(object): 118: ('iihh', None), 119: ('i', 'drop_bonus'), 120: ('i', 'set_automatic_orientation'), - 121: ('ii', None), + 121: ('ii', 'call_special_function'), 122: ('i', None), 123: ('i', 'skip_frames'), 124: ('i', 'drop_specific_bonus'),
--- a/pytouhou/game/bullet.py +++ b/pytouhou/game/bullet.py @@ -110,13 +110,23 @@ class Bullet(object): rec[2].extend(sprite._colors) + def set_anim(self, anim_idx=None, sprite_idx_offset=None): + if anim_idx is not None: + self.anim_idx = anim_idx + + if sprite_idx_offset is not None: + self.sprite_idx_offset = sprite_idx_offset + + self._sprite = Sprite() + anm_wrapper = self._game_state.resource_loader.get_anm_wrapper(('etama3.anm',)) #TODO + self._anmrunner = ANMRunner(anm_wrapper, self.anim_idx, + self._sprite, self.sprite_idx_offset) + + def update(self): if not self._sprite or self._sprite._removed: self._launched = True - self._sprite = Sprite() - anm_wrapper = self._game_state.resource_loader.get_anm_wrapper(('etama3.anm',)) #TODO - self._anmrunner = ANMRunner(anm_wrapper, self.anim_idx, - self._sprite, self.sprite_idx_offset) + self.set_anim() self._anmrunner.run_frame() self._sprite.update(angle_base=self.angle)
--- a/pytouhou/vm/eclrunner.py +++ b/pytouhou/vm/eclrunner.py @@ -13,7 +13,7 @@ ## -from math import atan2, cos, sin +from math import atan2, cos, sin, pi from pytouhou.utils.helpers import get_logger @@ -763,6 +763,21 @@ class ECLRunner(object): self._enemy.automatic_orientation = bool(flags & 1) + @instruction(121) + def call_special_function(self, function, arg): + if function == 0: # Cirno + if arg == 0: + for bullet in self._game_state.bullets: + bullet.speed = bullet.angle = 0. + bullet.set_anim(sprite_idx_offset=0) #TODO: check + else: + for bullet in self._game_state.bullets: + bullet.speed = 2.0 #TODO + bullet.angle = self._game_state.prng.rand_double() * pi #TODO + else: + logger.warn("Unimplemented special function %d!", function) + + @instruction(123) def skip_frames(self, frames): #TODO: is that all?