changeset 170:e7902309305c

Implement move anm instructions.
author Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
date Thu, 20 Oct 2011 03:15:55 -0700
parents c4b4f7c068f2
children 2f3665a77f11
files pytouhou/formats/anm0.py pytouhou/vm/anmrunner.py
diffstat 2 files changed, 21 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/pytouhou/formats/anm0.py
+++ b/pytouhou/formats/anm0.py
@@ -37,10 +37,10 @@ class Animations(object):
                      14: ('', 'set_blendmode_alphablend'),
                      15: ('', 'keep_still'),
                      16: ('ii', 'set_random_sprite'),
-                     17: ('fff', None),
-                     18: ('ffii', None),
-                     19: ('ffii', None),
-                     20: ('fffi', None),
+                     17: ('fff', 'set_3d_translation'),
+                     18: ('fffi', 'move_to_linear'),
+                     19: ('fffi', 'move_to_decel'),
+                     20: ('fffi', 'move_to_accel'),
                      21: ('', None),
                      22: ('i', None),
                      23: ('', 'set_corner_relative_placement'),
--- a/pytouhou/vm/anmrunner.py
+++ b/pytouhou/vm/anmrunner.py
@@ -176,9 +176,24 @@ class ANMRunner(object):
         self.load_sprite(min_idx + randrange(amp))
 
 
+    @instruction(17)
+    def move(self, x, y, z):
+        self._sprite.dest_offset = (x, y, z)
+
+
+    @instruction(18)
+    def move_in_linear(self, x, y, z, duration):
+        self._sprite.move_in(duration, x, y, z, lambda x: x)
+
+
     @instruction(19)
-    def move_in(self, x, y, z, duration):
-        self._sprite.move_in(duration, x, y, z, lambda x: x) #TODO: formula
+    def move_in_decel(self, x, y, z, duration):
+        self._sprite.move_in(duration, x, y, z, lambda x: 2. * x - x ** 2)
+
+
+    @instruction(20)
+    def move_in_accel(self, x, y, z, duration):
+        self._sprite.move_in(duration, x, y, z, lambda x: x ** 2)
 
 
     @instruction(23)