Mercurial > touhou
changeset 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 | dd2bd7283bec |
children | 3893a6fc66f1 |
files | pytouhou/game/enemy.py pytouhou/ui/gamerenderer.pyx pytouhou/vm/eclrunner.py |
diffstat | 3 files changed, 35 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/pytouhou/game/enemy.py +++ b/pytouhou/game/enemy.py @@ -17,6 +17,7 @@ from pytouhou.utils.interpolator import from pytouhou.vm.anmrunner import ANMRunner from pytouhou.game.sprite import Sprite from pytouhou.game.bullet import Bullet +from pytouhou.game.effect import Effect from math import cos, sin, atan2, pi @@ -75,6 +76,12 @@ class Enemy(object): self.hitbox_half_size = (0, 0) self.screen_box = None + self.aux_anm = 8 * [None] + + + def objects(self): + return [anm for anm in self.aux_anm if anm] + def set_bullet_attributes(self, type_, anim, sprite_idx_offset, bullets_per_shot, number_of_shots, speed, speed2, @@ -181,6 +188,10 @@ class Enemy(object): self._game.new_particle((self.x, self.y), color, 4., 256) #TODO: find the real size. + def set_aux_anm(self, number, script): + self.aux_anm[number] = Effect((self.x, self.y), script, self._anm_wrapper) + + def set_pos(self, x, y, z): self.x, self.y = x, y self.interpolator = Interpolator((x, y)) @@ -349,5 +360,11 @@ class Enemy(object): if self.touchable: self.check_collisions() + for anm in self.aux_anm: + if anm: + anm.x = self.x + anm.y = self.y + anm.update() + self.frame += 1
--- a/pytouhou/ui/gamerenderer.pyx +++ b/pytouhou/ui/gamerenderer.pyx @@ -76,6 +76,7 @@ cdef class GameRenderer(Renderer): self.setup_camera(0, 0, 1) glDisable(GL_FOG) + self.render_elements(chain(*(enemy.objects() for enemy in game.enemies))) self.render_elements(game.enemies) self.render_elements(game.effects) self.render_elements(chain(game.players_bullets,
--- a/pytouhou/vm/eclrunner.py +++ b/pytouhou/vm/eclrunner.py @@ -744,8 +744,8 @@ class ECLRunner(object): @instruction(97) - def set_anim(self, sprite_index): - self._enemy.set_anim(sprite_index) + def set_anim(self, script): + self._enemy.set_anim(script) @instruction(98) @@ -754,6 +754,11 @@ class ECLRunner(object): self._enemy.set_anim(default) + @instruction(99) + def set_aux_anm(self, number, script): + self._enemy.set_aux_anm(number, script) + + @instruction(100) def set_death_anim(self, sprite_index): self._enemy.death_anim = sprite_index @@ -931,6 +936,16 @@ class ECLRunner(object): self._enemy.remaining_lives = lives + @instruction(128) + def interrupt(self, event): + self._enemy._anmrunner.interrupt(event) + + + @instruction(129) + def interrupt_aux(self, number, event): + self._enemy.aux_anm[number]._anmrunner.interrupt(event) + + @instruction(132) def set_visible(self, value): self._enemy._visible = bool(value)