Mercurial > touhou
comparison pytouhou/vm/anmrunner.py @ 489:59bd29568753
Remove identity lambda for interpolators, improves performances slightly.
author | Emmanuel Gil Peyrot <linkmauve@linkmauve.fr> |
---|---|
date | Fri, 04 Oct 2013 11:19:04 +0200 |
parents | 98995d8ac744 |
children | e4c9eafab6d0 |
comparison
equal
deleted
inserted
replaced
488:791faab05445 | 489:59bd29568753 |
---|---|
26 __slots__ = ('_anm', '_sprite', 'running', 'sprite_index_offset', 'script', | 26 __slots__ = ('_anm', '_sprite', 'running', 'sprite_index_offset', 'script', |
27 'instruction_pointer', 'frame', 'waiting', 'handlers', | 27 'instruction_pointer', 'frame', 'waiting', 'handlers', |
28 'variables', 'version', 'timeout') | 28 'variables', 'version', 'timeout') |
29 | 29 |
30 #TODO: check! | 30 #TODO: check! |
31 formulae = {0: lambda x: x, | 31 formulae = {0: None, |
32 1: lambda x: x ** 2, | 32 1: lambda x: x ** 2, |
33 2: lambda x: x ** 3, | 33 2: lambda x: x ** 3, |
34 3: lambda x: x ** 4, | 34 3: lambda x: x ** 4, |
35 4: lambda x: 2 * x - x ** 2, | 35 4: lambda x: 2 * x - x ** 2, |
36 5: lambda x: 2 * x - x ** 3, | 36 5: lambda x: 2 * x - x ** 3, |
37 6: lambda x: 2 * x - x ** 4, | 37 6: lambda x: 2 * x - x ** 4, |
38 7: lambda x: x, | 38 7: None, |
39 255: lambda x: x} #XXX | 39 255: None} #XXX |
40 | 40 |
41 def __init__(self, anm, script_id, sprite, sprite_index_offset=0): | 41 def __init__(self, anm, script_id, sprite, sprite_index_offset=0): |
42 self._anm = anm | 42 self._anm = anm |
43 self._sprite = sprite | 43 self._sprite = sprite |
44 self.running = True | 44 self.running = True |
183 | 183 |
184 | 184 |
185 @instruction(12) | 185 @instruction(12) |
186 @instruction(15, 7) | 186 @instruction(15, 7) |
187 def fade(self, new_alpha, duration): | 187 def fade(self, new_alpha, duration): |
188 self._sprite.fade(duration, new_alpha, lambda x: x) #TODO: formula | 188 self._sprite.fade(duration, new_alpha) |
189 | 189 |
190 | 190 |
191 @instruction(13) | 191 @instruction(13) |
192 def set_blendfunc_alphablend(self): | 192 def set_blendfunc_alphablend(self): |
193 self._sprite.blendfunc = 1 | 193 self._sprite.blendfunc = 1 |
216 | 216 |
217 | 217 |
218 @instruction(18) | 218 @instruction(18) |
219 @instruction(17, 7) | 219 @instruction(17, 7) |
220 def move_in_linear(self, x, y, z, duration): | 220 def move_in_linear(self, x, y, z, duration): |
221 self._sprite.move_in(duration, x, y, z, lambda x: x) | 221 self._sprite.move_in(duration, x, y, z) |
222 | 222 |
223 | 223 |
224 @instruction(19) | 224 @instruction(19) |
225 @instruction(18, 7) | 225 @instruction(18, 7) |
226 def move_in_decel(self, x, y, z, duration): | 226 def move_in_decel(self, x, y, z, duration): |
298 | 298 |
299 | 299 |
300 @instruction(30) | 300 @instruction(30) |
301 @instruction(29, 7) | 301 @instruction(29, 7) |
302 def scale_in(self, sx, sy, duration): | 302 def scale_in(self, sx, sy, duration): |
303 self._sprite.scale_in(duration, sx, sy, lambda x: x) #TODO: formula | 303 self._sprite.scale_in(duration, sx, sy) |
304 | 304 |
305 | 305 |
306 # Now are the instructions new to anm2. | 306 # Now are the instructions new to anm2. |
307 | 307 |
308 | 308 |