changeset 17:d940d004b840

Make game.sprite.Sprite use its own frame counter.
author Thibaut Girka <thib@sitedethib.com>
date Tue, 09 Aug 2011 11:40:13 +0200
parents 66ce9bb440ac
children ca26a84916cb
files pytouhou/game/background.py pytouhou/game/sprite.py
diffstat 2 files changed, 6 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/pytouhou/game/background.py
+++ b/pytouhou/game/background.py
@@ -50,7 +50,7 @@ class Background(object):
             faces = []
             for script_index, ox, oy, oz, width_override, height_override in obj.quads:
                 sprite = Sprite(self.anim, script_index)
-                sprite.update(0, width_override, height_override)
+                sprite.update(width_override, height_override)
                 uvs, vertices = sprite._uvs, tuple((x + ox, y + oy, z + oz) for x, y, z in sprite._vertices)
                 faces.append((vertices, uvs))
             self.objects.append(faces)
--- a/pytouhou/game/sprite.py
+++ b/pytouhou/game/sprite.py
@@ -11,6 +11,7 @@ class Sprite(object):
         self.rescale = (1., 1.)
         self.rotations_3d = (0., 0., 0.)
         self.corner_relative_placement = False
+        self.frame = 0
         self._uvs = []
         self._vertices = []
 
@@ -66,14 +67,16 @@ class Sprite(object):
 
 
 
-    def update(self, frame, override_width=0, override_height=0):
+    def update(self, override_width=0, override_height=0):
         properties = {}
         for time, instr_type, data in self.anm.scripts[self.script_index]:
-            if time == frame:
+            if time == self.frame:
                 if instr_type == 15: #Return
                     break
                 else:
                     properties[instr_type] = data
+        self.frame += 1
+
         if properties:
             if 1 in properties:
                 self.texcoords = self.anm.sprites[unpack('<I', properties[1])[0]]