# HG changeset patch # User Thibaut Girka # Date 1315080520 -7200 # Node ID f5f9b5eb69a305da69bf8f119f4431480779412a # Parent 211e84207b3bc3164308a80a9581ccb36603f8dc Handle one more ANM instruction, and handle sprite indexes offsets diff --git a/pytouhou/formats/anm0.py b/pytouhou/formats/anm0.py --- a/pytouhou/formats/anm0.py +++ b/pytouhou/formats/anm0.py @@ -46,7 +46,7 @@ class Animations(object): 23: ('', 'set_corner_relative_placement'), 24: ('', None), 25: ('i', 'set_allow_offset'), #TODO: better name - 26: ('i', None), + 26: ('i', 'set_automatic_orientation'), 27: ('f', 'shift_texture_x'), 28: ('f', 'shift_texture_y'), 30: ('ffi', 'scale_in'), diff --git a/pytouhou/game/sprite.py b/pytouhou/game/sprite.py --- a/pytouhou/game/sprite.py +++ b/pytouhou/game/sprite.py @@ -47,6 +47,8 @@ class Sprite(object): self.fade_interpolator = None self.offset_interpolator = None + self.automatic_orientation = False + self.blendfunc = 0 # 0 = Normal, 1 = saturate #TODO: proper constants self.texcoords = (0, 0, 0, 0) # x, y, width, height diff --git a/pytouhou/vm/anmrunner.py b/pytouhou/vm/anmrunner.py --- a/pytouhou/vm/anmrunner.py +++ b/pytouhou/vm/anmrunner.py @@ -24,10 +24,11 @@ logger = get_logger(__name__) class ANMRunner(object): __metaclass__ = MetaRegistry __slots__ = ('_anm_wrapper', '_sprite', '_running', + 'sprite_index_offset', 'script', 'instruction_pointer', 'frame') - def __init__(self, anm_wrapper, script_id, sprite): + def __init__(self, anm_wrapper, script_id, sprite, sprite_index_offset=0): self._anm_wrapper = anm_wrapper self._sprite = sprite self._running = True @@ -35,7 +36,8 @@ class ANMRunner(object): anm, self.script = anm_wrapper.get_script(script_id) self.frame = 0 self.instruction_pointer = 0 - pass + + self.sprite_index_offset = sprite_index_offset def run_frame(self): @@ -73,7 +75,7 @@ class ANMRunner(object): @instruction(1) def load_sprite(self, sprite_index): - self._sprite.anm, self._sprite.texcoords = self._anm_wrapper.get_sprite(sprite_index) + self._sprite.anm, self._sprite.texcoords = self._anm_wrapper.get_sprite(sprite_index + self.sprite_index_offset) @instruction(2) @@ -159,6 +161,13 @@ class ANMRunner(object): self._sprite.allow_dest_offset = bool(value) + @instruction(26) + def set_automatic_orientation(self, value): + """If true, rotate by pi-angle around the z axis. + """ + self._sprite.automatic_orientation = bool(value) + + @instruction(27) def shift_texture_x(self, dx): tox, toy = self._sprite.texoffsets