- surface, (255, 255, 0),
- pymunk.pygame_util.to_pygame(self.position, surface), 5)
- for shape in self.body.shapes:
- pygame_poly = [
- pymunk.pygame_util.to_pygame(v, surface) for v in
- shape.get_vertices()]
- pygame.draw.polygon(
- subsurface, (200, 200, 200), pygame_poly, 0)
- pygame.draw.aalines(
- subsurface, (200, 200, 200), True, pygame_poly, 1)
- subsurface.set_alpha(200)
- surface.blit(subsurface, (0, 0), None)
+ 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")
+
+ ray_mask.blit(radius_mask, dest_rect, dest_rect, pgl.BLEND_RGBA_MULT)
+ dt.lap("blitted radius mask to ray mask")
+
+ surface.blit(ray_mask, dest_rect, dest_rect)
+ dt.lap("blitted surface")
+ dt.end()
+
+ def fitting_image(self):
+ if self._fitting_image is None:
+ fitting_colours = [COLOURS[c] for c in self.colour_cycle]
+ ncolour = len(fitting_colours)
+ if ncolour > 3:
+ print "Multicoloured light should not have more than 3 colours"
+ ncolour = 3
+
+ if ncolour == 1:
+ self._fitting_image = loader.load_image(
+ "48", self.FITTING_IMG,
+ transform=Multiply(colour=fitting_colours[0]))
+ else:
+ if self._colour_mult_image is None:
+ self._colour_mult_image = pygame.surface.Surface((48, 48))
+
+ for i in range(ncolour):
+ sector = loader.load_image(
+ "48", "light_mask_%d_%d.png" % (ncolour, i + 1),
+ transform=Multiply(colour=fitting_colours[i]))
+ self._colour_mult_image.blit(sector, (0,0), None, 0)
+
+ self._fitting_image = loader.load_image(
+ "48", self.FITTING_IMG,
+ transform=MultiplyImage(image=self._colour_mult_image))
+
+ return self._fitting_image
+
+ def invalidate_fitting_image(self):
+ self._fitting_image = None
+
+ def render_fitting(self, surface):
+ rx, ry = self.ray_manager.pygame_position(surface)
+ surface.blit(self.fitting_image(), (rx - 24, ry - 24), None, 0)
+
+ def power_usage(self):
+ if not self.on:
+ return 0.0
+ area = math.pi * (self.ray_manager.max_radius ** 2) # radius
+ area = area * (self.ray_manager.spread / (2 * math.pi)) # spread
+ return 5 * area * self.intensity
+
+ def base_damage(self):
+ return 5 * self.intensity
+
+ def toggle(self):
+ self.colour_pos += 1
+ if self.colour_pos >= len(self.colour_cycle):
+ self.colour = self.colour_cycle[0]
+ self.colour_pos = -1
+ self.on = False
+ else:
+ self.colour = self.colour_cycle[self.colour_pos]
+ self.on = True
+ self.invalidate_fitting_image()
+
+ def tick(self):
+ pass