Mercurial > touhou
comparison pytouhou/game/sprite.pyx @ 622:98603f2c32b4
Reduce the precision of Sprite’s variables.
| author | Emmanuel Gil Peyrot <linkmauve@linkmauve.fr> |
|---|---|
| date | Wed, 08 Apr 2015 15:05:34 +0200 |
| parents | e15672733c93 |
| children | df3c4ef5f2cc |
comparison
equal
deleted
inserted
replaced
| 621:398860bc3b7b | 622:98603f2c32b4 |
|---|---|
| 14 | 14 |
| 15 from libc.stdlib cimport free | 15 from libc.stdlib cimport free |
| 16 from libc.string cimport memcpy | 16 from libc.string cimport memcpy |
| 17 | 17 |
| 18 | 18 |
| 19 cdef class Sprite: | 19 cdef public class Sprite[object Sprite, type SpriteType]: |
| 20 def __dealloc__(self): | 20 def __dealloc__(self): |
| 21 if self._rendering_data != NULL: | 21 if self._rendering_data != NULL: |
| 22 free(self._rendering_data) | 22 free(self._rendering_data) |
| 23 | 23 |
| 24 | 24 |
| 116 return (self._texcoords[0], self._texcoords[1], self._texcoords[2], self._texcoords[3]) | 116 return (self._texcoords[0], self._texcoords[1], self._texcoords[2], self._texcoords[3]) |
| 117 def __set__(self, value): | 117 def __set__(self, value): |
| 118 self._texcoords[:] = [value[0], value[1], value[2], value[3]] | 118 self._texcoords[:] = [value[0], value[1], value[2], value[3]] |
| 119 | 119 |
| 120 | 120 |
| 121 cpdef fade(self, unsigned long duration, alpha, formula=None): | 121 cpdef fade(self, unsigned int duration, alpha, formula=None): |
| 122 self.fade_interpolator = Interpolator((self._color[3],), self.frame, | 122 self.fade_interpolator = Interpolator((self._color[3],), self.frame, |
| 123 (alpha,), self.frame + duration, | 123 (alpha,), self.frame + duration, |
| 124 formula) | 124 formula) |
| 125 | 125 |
| 126 | 126 |
| 127 cpdef scale_in(self, unsigned long duration, sx, sy, formula=None): | 127 cpdef scale_in(self, unsigned int duration, sx, sy, formula=None): |
| 128 self.scale_interpolator = Interpolator(self.rescale, self.frame, | 128 self.scale_interpolator = Interpolator(self.rescale, self.frame, |
| 129 (sx, sy), self.frame + duration, | 129 (sx, sy), self.frame + duration, |
| 130 formula) | 130 formula) |
| 131 | 131 |
| 132 | 132 |
| 133 cpdef move_in(self, unsigned long duration, x, y, z, formula=None): | 133 cpdef move_in(self, unsigned int duration, x, y, z, formula=None): |
| 134 self.offset_interpolator = Interpolator(self.dest_offset, self.frame, | 134 self.offset_interpolator = Interpolator(self.dest_offset, self.frame, |
| 135 (x, y, z), self.frame + duration, | 135 (x, y, z), self.frame + duration, |
| 136 formula) | 136 formula) |
| 137 | 137 |
| 138 | 138 |
| 139 cpdef rotate_in(self, unsigned long duration, rx, ry, rz, formula=None): | 139 cpdef rotate_in(self, unsigned int duration, rx, ry, rz, formula=None): |
| 140 self.rotation_interpolator = Interpolator(self.rotations_3d, self.frame, | 140 self.rotation_interpolator = Interpolator(self.rotations_3d, self.frame, |
| 141 (rx, ry, rz), self.frame + duration, | 141 (rx, ry, rz), self.frame + duration, |
| 142 formula) | 142 formula) |
| 143 | 143 |
| 144 | 144 |
| 145 cpdef change_color_in(self, unsigned long duration, r, g, b, formula=None): | 145 cpdef change_color_in(self, unsigned int duration, r, g, b, formula=None): |
| 146 self.color_interpolator = Interpolator(self.color, self.frame, | 146 self.color_interpolator = Interpolator(self.color, self.frame, |
| 147 (r, g, b), self.frame + duration, | 147 (r, g, b), self.frame + duration, |
| 148 formula) | 148 formula) |
| 149 | 149 |
| 150 | 150 |
