Mercurial > touhou
changeset 81:f5f9b5eb69a3
Handle one more ANM instruction, and handle sprite indexes offsets
author | Thibaut Girka <thib@sitedethib.com> |
---|---|
date | Sat, 03 Sep 2011 22:08:40 +0200 |
parents | 211e84207b3b |
children | de48213a02bf |
files | pytouhou/formats/anm0.py pytouhou/game/sprite.py pytouhou/vm/anmrunner.py |
diffstat | 3 files changed, 15 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- 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'),
--- 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
--- 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