changeset 240:02de1563fa18

Fix ANM wait, translation/rotation order, and partially implement ANM0 instruction 24
author Thibaut Girka <thib@sitedethib.com>
date Sun, 01 Jan 2012 23:51:01 +0100
parents 901489c21d19
children dd2bd7283bec
files pytouhou/ui/sprite.pyx pytouhou/vm/anmrunner.py
diffstat 2 files changed, 15 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/pytouhou/ui/sprite.pyx
+++ b/pytouhou/ui/sprite.pyx
@@ -44,8 +44,6 @@ cpdef object get_sprite_rendering_data(o
     elif sprite.force_rotation:
         rz += sprite.angle
 
-    if sprite.allow_dest_offset:
-        vertmat.translate(sprite.dest_offset[0], sprite.dest_offset[1], sprite.dest_offset[2])
     if (rx, ry, rz) != (0., 0., 0.):
         if rx:
             vertmat.rotate_x(-rx)
@@ -53,6 +51,8 @@ cpdef object get_sprite_rendering_data(o
             vertmat.rotate_y(ry)
         if rz:
             vertmat.rotate_z(-rz) #TODO: minus, really?
+    if sprite.allow_dest_offset:
+        vertmat.translate(sprite.dest_offset[0], sprite.dest_offset[1], sprite.dest_offset[2])
     if sprite.corner_relative_placement: # Reposition
         vertmat.translate(width / 2., height / 2., 0.)
 
--- a/pytouhou/vm/anmrunner.py
+++ b/pytouhou/vm/anmrunner.py
@@ -58,12 +58,9 @@ class ANMRunner(object):
         if not self._running:
             return False
 
-        if self.waiting:
-            return True
-
         sprite = self._sprite
 
-        while self._running:
+        while self._running and not self.waiting:
             frame, opcode, args = self.script[self.instruction_pointer]
 
             if frame > self.frame:
@@ -79,6 +76,10 @@ class ANMRunner(object):
                 else:
                     callback(self, *args)
                     sprite._changed = True
+
+        if self.waiting:
+            return True
+
         self.frame += 1
 
         # Update sprite
@@ -230,6 +231,14 @@ class ANMRunner(object):
         self._sprite.corner_relative_placement = True #TODO
 
 
+    @instruction(24)
+    def wait_ex(self):
+        """Hide/delete the sprite and wait for an interrupt.
+        """
+        #TODO: Hide/delete the sprite and figure what happens exactly
+        self.waiting = True
+
+
     @instruction(25)
     def set_allow_dest_offset(self, value):
         self._sprite.allow_dest_offset = bool(value)