Mercurial > touhou
comparison pytouhou/vm/anmrunner.py @ 120:4300a832f033
Small refactoring and massive performance improvement
author | Thibaut Girka <thib@sitedethib.com> |
---|---|
date | Thu, 08 Sep 2011 12:46:05 +0200 |
parents | f5f9b5eb69a3 |
children | 174324a4da51 |
comparison
equal
deleted
inserted
replaced
119:fad7b44cebf2 | 120:4300a832f033 |
---|---|
62 logger.warn('unhandled opcode %d (args: %r)', instr_type, args) | 62 logger.warn('unhandled opcode %d (args: %r)', instr_type, args) |
63 else: | 63 else: |
64 callback(self, *args) | 64 callback(self, *args) |
65 self._sprite._changed = True | 65 self._sprite._changed = True |
66 self.frame += 1 | 66 self.frame += 1 |
67 | |
68 # Update sprite | |
69 sprite = self._sprite | |
70 sprite.frame += 1 | |
71 | |
72 if sprite.rotations_speed_3d != (0., 0., 0.): | |
73 ax, ay, az = sprite.rotations_3d | |
74 sax, say, saz = sprite.rotations_speed_3d | |
75 sprite.rotations_3d = ax + sax, ay + say, az + saz | |
76 sprite._changed = True | |
77 | |
78 if sprite.scale_speed != (0., 0.): | |
79 rx, ry = sprite.rescale | |
80 rsx, rsy = sprite.scale_speed | |
81 sprite.rescale = rx + rsx, ry + rsy | |
82 sprite._changed = True | |
83 | |
84 if sprite.fade_interpolator: | |
85 sprite.fade_interpolator.update(sprite.frame) | |
86 sprite.alpha = int(sprite.fade_interpolator.values[0]) | |
87 sprite._changed = True | |
88 | |
89 if sprite.scale_interpolator: | |
90 sprite.scale_interpolator.update(sprite.frame) | |
91 sprite.rescale = sprite.scale_interpolator.values | |
92 sprite._changed = True | |
93 | |
94 if sprite.offset_interpolator: | |
95 sprite.offset_interpolator.update(sprite.frame) | |
96 sprite.dest_offset = sprite.offset_interpolator.values | |
97 sprite._changed = True | |
98 | |
67 return self._running | 99 return self._running |
68 | 100 |
69 | 101 |
70 @instruction(0) | 102 @instruction(0) |
71 def remove(self): | 103 def remove(self): |