changeset 27:b65d6bc55793

Add rotating sprite support
author Thibaut Girka <thib@sitedethib.com>
date Fri, 12 Aug 2011 21:38:28 +0200
parents f17122405121
children f405b947624d
files pytouhou/game/sprite.py
diffstat 1 files changed, 9 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/pytouhou/game/sprite.py
+++ b/pytouhou/game/sprite.py
@@ -22,6 +22,7 @@ class Sprite(object):
         self.mirrored = False
         self.rescale = (1., 1.)
         self.rotations_3d = (0., 0., 0.)
+        self.rotations_speed_3d = (0., 0., 0.)
         self.corner_relative_placement = False
         self.frame = 0
         self._uvs = []
@@ -89,6 +90,8 @@ class Sprite(object):
                     properties[instr_type] = data
         self.frame += 1
 
+        self.rotations_3d = tuple(x + y for x, y in zip(self.rotations_3d, self.rotations_speed_3d))
+
         if properties:
             if 1 in properties:
                 self.texcoords = self.anm.sprites[unpack('<I', properties[1])[0]]
@@ -105,6 +108,9 @@ class Sprite(object):
             if 9 in properties:
                 self.rotations_3d = unpack('<fff', properties[9])
                 del properties[9]
+            if 10 in properties:
+                self.rotations_speed_3d = unpack('<fff', properties[10])
+                del properties[10]
             if 23 in properties:
                 self.corner_relative_placement = True #TODO
                 del properties[23]
@@ -112,5 +118,8 @@ class Sprite(object):
                 print('Leftover properties: %r' % properties) #TODO
             self.update_uvs_vertices(override_width, override_height)
             return True
+        if self.rotations_speed_3d != (0., 0., 0.):
+            self.update_uvs_vertices(override_width, override_height)
+            return True
         return False