Mercurial > touhou
comparison pytouhou/vm/anmrunner.py @ 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 | 6a08f44fa01b |
children | 4300a832f033 |
comparison
equal
deleted
inserted
replaced
80:211e84207b3b | 81:f5f9b5eb69a3 |
---|---|
22 | 22 |
23 | 23 |
24 class ANMRunner(object): | 24 class ANMRunner(object): |
25 __metaclass__ = MetaRegistry | 25 __metaclass__ = MetaRegistry |
26 __slots__ = ('_anm_wrapper', '_sprite', '_running', | 26 __slots__ = ('_anm_wrapper', '_sprite', '_running', |
27 'sprite_index_offset', | |
27 'script', 'instruction_pointer', 'frame') | 28 'script', 'instruction_pointer', 'frame') |
28 | 29 |
29 | 30 |
30 def __init__(self, anm_wrapper, script_id, sprite): | 31 def __init__(self, anm_wrapper, script_id, sprite, sprite_index_offset=0): |
31 self._anm_wrapper = anm_wrapper | 32 self._anm_wrapper = anm_wrapper |
32 self._sprite = sprite | 33 self._sprite = sprite |
33 self._running = True | 34 self._running = True |
34 | 35 |
35 anm, self.script = anm_wrapper.get_script(script_id) | 36 anm, self.script = anm_wrapper.get_script(script_id) |
36 self.frame = 0 | 37 self.frame = 0 |
37 self.instruction_pointer = 0 | 38 self.instruction_pointer = 0 |
38 pass | 39 |
40 self.sprite_index_offset = sprite_index_offset | |
39 | 41 |
40 | 42 |
41 def run_frame(self): | 43 def run_frame(self): |
42 if self._sprite._removed: | 44 if self._sprite._removed: |
43 return False | 45 return False |
71 self._running = True | 73 self._running = True |
72 | 74 |
73 | 75 |
74 @instruction(1) | 76 @instruction(1) |
75 def load_sprite(self, sprite_index): | 77 def load_sprite(self, sprite_index): |
76 self._sprite.anm, self._sprite.texcoords = self._anm_wrapper.get_sprite(sprite_index) | 78 self._sprite.anm, self._sprite.texcoords = self._anm_wrapper.get_sprite(sprite_index + self.sprite_index_offset) |
77 | 79 |
78 | 80 |
79 @instruction(2) | 81 @instruction(2) |
80 def set_scale(self, sx, sy): | 82 def set_scale(self, sx, sy): |
81 self._sprite.rescale = sx, sy | 83 self._sprite.rescale = sx, sy |
157 @instruction(25) | 159 @instruction(25) |
158 def set_allow_dest_offset(self, value): | 160 def set_allow_dest_offset(self, value): |
159 self._sprite.allow_dest_offset = bool(value) | 161 self._sprite.allow_dest_offset = bool(value) |
160 | 162 |
161 | 163 |
164 @instruction(26) | |
165 def set_automatic_orientation(self, value): | |
166 """If true, rotate by pi-angle around the z axis. | |
167 """ | |
168 self._sprite.automatic_orientation = bool(value) | |
169 | |
170 | |
162 @instruction(27) | 171 @instruction(27) |
163 def shift_texture_x(self, dx): | 172 def shift_texture_x(self, dx): |
164 tox, toy = self._sprite.texoffsets | 173 tox, toy = self._sprite.texoffsets |
165 self._sprite.texoffsets = tox + dx, toy | 174 self._sprite.texoffsets = tox + dx, toy |
166 | 175 |