changeset 433:1222341ea22c

Always run the first frame of an ANMRunner.
author Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
date Sun, 11 Aug 2013 14:23:50 +0200
parents d4874ebaa06e
children 18e4b121646b
files pytouhou/game/background.py pytouhou/game/bullet.pyx pytouhou/game/effect.py pytouhou/game/enemy.py pytouhou/game/face.py pytouhou/game/laser.py pytouhou/game/orb.py pytouhou/game/player.py pytouhou/game/text.py pytouhou/vm/anmrunner.py
diffstat 10 files changed, 3 insertions(+), 16 deletions(-) [+]
line wrap: on
line diff
--- a/pytouhou/game/background.py
+++ b/pytouhou/game/background.py
@@ -54,7 +54,6 @@ class Background(object):
             for script_index, ox, oy, oz, width_override, height_override in obj.quads:
                 sprite = Sprite(width_override, height_override)
                 anm_runner = ANMRunner(self.anm, script_index, sprite)
-                anm_runner.run_frame()
                 quads.append((ox, oy, oz, width_override, height_override, sprite))
                 self.anm_runners.append(anm_runner)
             self.models.append(quads)
--- a/pytouhou/game/bullet.pyx
+++ b/pytouhou/game/bullet.pyx
@@ -82,7 +82,6 @@ cdef class Bullet(object):
             self.anmrunner = ANMRunner(bullet_type.anm,
                                         index, self.sprite,
                                         bullet_type.launch_anim_offsets[sprite_idx_offset])
-            self.anmrunner.run_frame()
         else:
             self.launch()
 
@@ -119,7 +118,6 @@ cdef class Bullet(object):
             self.sprite.angle = self.angle
         self.anmrunner = ANMRunner(bt.anm, bt.anim_index,
                                    self.sprite, self.sprite_idx_offset)
-        self.anmrunner.run_frame()
 
 
     def launch(self):
@@ -148,7 +146,6 @@ cdef class Bullet(object):
             self.sprite.angle = self.angle
         self.anmrunner = ANMRunner(bt.anm, bt.cancel_anim_index,
                                    self.sprite, bt.launch_anim_offsets[self.sprite_idx_offset])
-        self.anmrunner.run_frame()
         self.dx, self.dy = self.dx / 2., self.dy / 2.
 
         self.state = CANCELLED
--- a/pytouhou/game/effect.py
+++ b/pytouhou/game/effect.py
@@ -23,7 +23,6 @@ class Effect(object):
     def __init__(self, pos, index, anm):
         self.sprite = Sprite()
         self.anmrunner = ANMRunner(anm, index, self.sprite)
-        self.anmrunner.run_frame()
         self.removed = False
         self.objects = [self]
 
--- a/pytouhou/game/enemy.py
+++ b/pytouhou/game/enemy.py
@@ -224,7 +224,6 @@ class Enemy(object):
         entry = 0 if index in self._anms[0].scripts else 1
         self.sprite = Sprite()
         self.anmrunner = ANMRunner(self._anms[entry], index, self.sprite)
-        self.anmrunner.run_frame()
 
 
     def die_anim(self):
--- a/pytouhou/game/face.py
+++ b/pytouhou/game/face.py
@@ -41,7 +41,6 @@ class Face(object):
 
     def load(self, index):
         self.sprite.anm, self.sprite.texcoords = self._anms[self.side][index]
-        self.anmrunner.run_frame()
 
 
     def update(self):
--- a/pytouhou/game/laser.py
+++ b/pytouhou/game/laser.py
@@ -100,7 +100,6 @@ class Laser(object):
         self.sprite.angle = self.angle
         self.anmrunner = ANMRunner(lt.anm, lt.anim_index,
                                    self.sprite, self.sprite_idx_offset)
-        self.anmrunner.run_frame()
 
 
     def _check_collision(self, point, border_size):
@@ -238,7 +237,6 @@ class PlayerLaser(object):
         self.anmrunner = ANMRunner(lt.anm, lt.anim_index,
                                    self.sprite, self.sprite_idx_offset)
         #self.sprite.blendfunc = 1 #XXX
-        self.anmrunner.run_frame()
 
 
     def cancel(self):
--- a/pytouhou/game/orb.py
+++ b/pytouhou/game/orb.py
@@ -24,7 +24,6 @@ class Orb(object):
     def __init__(self, anm, index, player_state, fire_func):
         self.sprite = Sprite()
         self.anmrunner = ANMRunner(anm, index, self.sprite)
-        self.anmrunner.run_frame()
 
         self.offset_x = 0
         self.offset_y = 0
--- a/pytouhou/game/player.py
+++ b/pytouhou/game/player.py
@@ -87,7 +87,6 @@ class Player(object):
     def set_anim(self, index):
         self.sprite = Sprite()
         self.anmrunner = ANMRunner(self.anm, index, self.sprite)
-        self.anmrunner.run_frame()
 
 
     def play_sound(self, name):
@@ -280,7 +279,6 @@ class Player(object):
                 self.sprite.fade(30, 255, lambda x: x)
                 self.sprite.blendfunc = 1
                 self.sprite.scale_in(30, 1., 1., lambda x: x)
-                self.anmrunner.run_frame()
 
             elif time == 61: # respawned
                 self.state.touchable = True
--- a/pytouhou/game/text.py
+++ b/pytouhou/game/text.py
@@ -40,7 +40,6 @@ class Widget(object):
         if back_anm:
             self.sprite = Sprite()
             self.anmrunner = ANMRunner(back_anm, back_script, self.sprite)
-            self.anmrunner.run_frame()
 
         self.x, self.y = pos
 
@@ -64,8 +63,7 @@ class GlyphCollection(Widget):
         self.xspacing = xspacing
 
         # Set up ref sprite
-        anm_runner = ANMRunner(anm, ref_script, self.ref_sprite)
-        anm_runner.run_frame()
+        ANMRunner(anm, ref_script, self.ref_sprite)
         self.ref_sprite.corner_relative_placement = True #TODO: perhaps not right
 
 
@@ -225,7 +223,6 @@ class Gauge(object):
     def __init__(self, pos, anm, max_length=280, maximum=1, value=0):
         self.sprite = Sprite()
         self.anmrunner = ANMRunner(anm, 21, self.sprite)
-        self.anmrunner.run_frame()
         self.removed = False
         self.sprite.corner_relative_placement = True #TODO: perhaps not right
         self.objects = [self]
--- a/pytouhou/vm/anmrunner.py
+++ b/pytouhou/vm/anmrunner.py
@@ -56,6 +56,8 @@ class ANMRunner(object):
 
         self.sprite_index_offset = sprite_index_offset
 
+        self.run_frame()
+
 
     def interrupt(self, interrupt):
         new_ip = self.script.interrupts.get(interrupt, None)