# HG changeset patch # User Emmanuel Gil Peyrot # Date 1319105755 25200 # Node ID e7902309305c0d7160eea151f58d5e3f5086bc51 # Parent c4b4f7c068f29e22dc826de204bd646f6d801f02 Implement move anm instructions. diff --git a/pytouhou/formats/anm0.py b/pytouhou/formats/anm0.py --- 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'), diff --git a/pytouhou/vm/anmrunner.py b/pytouhou/vm/anmrunner.py --- 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)