changeset 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 398860bc3b7b
children df6ae915ebaa
files pytouhou/game/sprite.pxd pytouhou/game/sprite.pyx
diffstat 2 files changed, 20 insertions(+), 20 deletions(-) [+]
line wrap: on
line diff
--- a/pytouhou/game/sprite.pxd
+++ b/pytouhou/game/sprite.pxd
@@ -1,9 +1,9 @@
 from pytouhou.utils.interpolator cimport Interpolator
 from pytouhou.formats.animation cimport Animation
 
-cdef class Sprite:
-    cdef public long blendfunc, frame
-    cdef public double width_override, height_override, angle
+cdef public class Sprite[object Sprite, type SpriteType]:
+    cdef public int blendfunc, frame
+    cdef public float width_override, height_override, angle
     cdef public bint removed, changed, visible, force_rotation
     cdef public bint automatic_orientation, allow_dest_offset, mirrored
     cdef public bint corner_relative_placement
@@ -15,19 +15,19 @@ cdef class Sprite:
     cdef void *_rendering_data
 
     cdef float _dest_offset[3]
-    cdef double _texcoords[4]
-    cdef double _texoffsets[2]
-    cdef double _rescale[2]
-    cdef double _scale_speed[2]
-    cdef double _rotations_3d[3]
-    cdef double _rotations_speed_3d[3]
+    cdef float _texcoords[4]
+    cdef float _texoffsets[2]
+    cdef float _rescale[2]
+    cdef float _scale_speed[2]
+    cdef float _rotations_3d[3]
+    cdef float _rotations_speed_3d[3]
     cdef unsigned char _color[4]
 
-    cpdef fade(self, unsigned long duration, alpha, formula=*)
-    cpdef scale_in(self, unsigned long duration, sx, sy, formula=*)
-    cpdef move_in(self, unsigned long duration, x, y, z, formula=*)
-    cpdef rotate_in(self, unsigned long duration, rx, ry, rz, formula=*)
-    cpdef change_color_in(self, unsigned long duration, r, g, b, formula=*)
+    cpdef fade(self, unsigned int duration, alpha, formula=*)
+    cpdef scale_in(self, unsigned int duration, sx, sy, formula=*)
+    cpdef move_in(self, unsigned int duration, x, y, z, formula=*)
+    cpdef rotate_in(self, unsigned int duration, rx, ry, rz, formula=*)
+    cpdef change_color_in(self, unsigned int duration, r, g, b, formula=*)
     cpdef update_orientation(self, double angle_base=*, bint force_rotation=*)
     cpdef Sprite copy(self)
     cpdef update(self)
--- a/pytouhou/game/sprite.pyx
+++ b/pytouhou/game/sprite.pyx
@@ -16,7 +16,7 @@ from libc.stdlib cimport free
 from libc.string cimport memcpy
 
 
-cdef class Sprite:
+cdef public class Sprite[object Sprite, type SpriteType]:
     def __dealloc__(self):
         if self._rendering_data != NULL:
             free(self._rendering_data)
@@ -118,31 +118,31 @@ cdef class Sprite:
             self._texcoords[:] = [value[0], value[1], value[2], value[3]]
 
 
-    cpdef fade(self, unsigned long duration, alpha, formula=None):
+    cpdef fade(self, unsigned int duration, alpha, formula=None):
         self.fade_interpolator = Interpolator((self._color[3],), self.frame,
                                               (alpha,), self.frame + duration,
                                               formula)
 
 
-    cpdef scale_in(self, unsigned long duration, sx, sy, formula=None):
+    cpdef scale_in(self, unsigned int duration, sx, sy, formula=None):
         self.scale_interpolator = Interpolator(self.rescale, self.frame,
                                                (sx, sy), self.frame + duration,
                                                formula)
 
 
-    cpdef move_in(self, unsigned long duration, x, y, z, formula=None):
+    cpdef move_in(self, unsigned int duration, x, y, z, formula=None):
         self.offset_interpolator = Interpolator(self.dest_offset, self.frame,
                                                 (x, y, z), self.frame + duration,
                                                 formula)
 
 
-    cpdef rotate_in(self, unsigned long duration, rx, ry, rz, formula=None):
+    cpdef rotate_in(self, unsigned int duration, rx, ry, rz, formula=None):
         self.rotation_interpolator = Interpolator(self.rotations_3d, self.frame,
                                                   (rx, ry, rz), self.frame + duration,
                                                   formula)
 
 
-    cpdef change_color_in(self, unsigned long duration, r, g, b, formula=None):
+    cpdef change_color_in(self, unsigned int duration, r, g, b, formula=None):
         self.color_interpolator = Interpolator(self.color, self.frame,
                                                (r, g, b), self.frame + duration,
                                                formula)