55 FPS, remove a blit.
authorSimon Cross <hodgestar@gmail.com>
Fri, 9 Sep 2016 19:57:29 +0000 (21:57 +0200)
committerSimon Cross <hodgestar@gmail.com>
Fri, 9 Sep 2016 19:57:29 +0000 (21:57 +0200)
tabakrolletjie/lights.py

index 108f795097738e0470d436f7716736cf66106cd1..59bbe173bccc20ff36d5402cc2b65ca9a7aa10bc 100644 (file)
@@ -178,10 +178,14 @@ class BaseLight(object):
             pygame.draw.polygon(ray_mask, white, pygame_poly, 1)
         dt.lap("ray mask rendered")
 
+        light_colour = self.COLOURS[self.colour]
+        intensity = int(255 * self.intensity)
+        light_colour = light_colour + (intensity,)
+
         radius_mask.fill(black)
         centre = pymunk.pygame_util.to_pygame(self.position, surface)
         pygame.draw.circle(
-            radius_mask, white, centre, int(max_radius), 0)
+            radius_mask, light_colour, centre, int(max_radius), 0)
         pygame.draw.circle(
             radius_mask, black, centre, int(min_radius), 0)
         dt.lap("radius mask rendered")
@@ -189,13 +193,6 @@ class BaseLight(object):
         ray_mask.blit(radius_mask, dest_rect, dest_rect, pgl.BLEND_RGBA_MULT)
         dt.lap("blitted radius mask to ray mask")
 
-        light_colour = self.COLOURS[self.colour]
-        intensity = int(255 * self.intensity)
-        light_colour = light_colour + (intensity,)
-
-        ray_mask.fill(light_colour, dest_rect, pgl.BLEND_RGBA_MULT)
-        dt.lap("coloured ray mask")
-
         surface.blit(ray_mask, dest_rect, dest_rect)
         dt.lap("blitted surface")
         dt.end()