diff pytouhou/game/sprite.pyx @ 532:dacdcca59b66

Don’t put back the rendering data into a tuple, use a specialised struct inside Sprite to pass it to the renderer.
author Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
date Thu, 19 Dec 2013 21:55:26 +0100
parents 0b2a92a25245
children e15672733c93
line wrap: on
line diff
--- a/pytouhou/game/sprite.pyx
+++ b/pytouhou/game/sprite.pyx
@@ -12,7 +12,16 @@
 ## GNU General Public License for more details.
 ##
 
+from libc.stdlib cimport free
+from libc.string cimport memcpy
+
+
 cdef class Sprite:
+    def __dealloc__(self):
+        if self._rendering_data != NULL:
+            free(self._rendering_data)
+
+
     def __init__(self, width_override=0, height_override=0):
         self.anm = None
         self.removed = False
@@ -51,8 +60,6 @@ cdef class Sprite:
         for i in xrange(4):
             self._color[i] = 255
 
-        self._rendering_data = None
-
 
     property scale_speed:
         def __get__(self):
@@ -181,7 +188,6 @@ cdef class Sprite:
 
         sprite.alpha = self.alpha
         sprite.anm = self.anm
-        sprite._rendering_data = self._rendering_data
 
         return sprite