changeset 467:5bb7d2c0ff46

Fix lasers sprite handling
author Thibaut Girka <thib@sitedethib.com>
date Thu, 12 Sep 2013 14:43:38 +0200
parents b16d34fca5b4
children feecdb4a8928
files pytouhou/game/laser.py pytouhou/game/sprite.pxd
diffstat 2 files changed, 7 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/pytouhou/game/laser.py
+++ b/pytouhou/game/laser.py
@@ -183,8 +183,9 @@ class Laser(Element):
 
         offset = self.end_offset - length / 2.
         self.x, self.y = self.base_pos[0] + offset * cos(self.angle), self.base_pos[1] + offset * sin(self.angle)
-        self.sprite.width_override = width or 0.01 #TODO
-        self.sprite.height_override = length or 0.01 #TODO
+        self.sprite.visible = (width > 0 and length > 0)
+        self.sprite.width_override = width
+        self.sprite.height_override = length
 
         self.sprite.update_orientation(pi/2. - self.angle, True)
         self.sprite.changed = True #TODO
@@ -247,7 +248,8 @@ class PlayerLaser(Element):
         if self.frame == self.duration:
             self.cancel()
 
-        self.sprite.height_override = length or 0.01 #TODO
+        self.sprite.visible = (length > 0)
+        self.sprite.height_override = length
         self.sprite.changed = True #TODO
 
         self.frame += 1
--- a/pytouhou/game/sprite.pxd
+++ b/pytouhou/game/sprite.pxd
@@ -1,8 +1,8 @@
 from pytouhou.utils.interpolator cimport Interpolator
 
 cdef class Sprite:
-    cdef public long width_override, height_override, blendfunc, frame
-    cdef public double angle
+    cdef public long blendfunc, frame
+    cdef public double 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