+
+ FITTING_IMG = "lamp.png"
+
+
+class PulsatingLamp(BaseLight):
+
+ FITTING_IMG = "lamp.png"
+ DEFAULT_PULSE_RANGE = (20, 100)
+ DEFAULT_PULSE_VELOCITY = 2
+ DEFAULT_INTENSITY_RANGE = (0.0, 0.9)
+ DEFAULT_INTENSITY_VELOCITY = 0.1
+
+ def __init__(self, **kw):
+ self.pulse_range = kw.pop("pulse_range", self.DEFAULT_PULSE_RANGE)
+ self.pulse_velocity = kw.pop(
+ "pulse_velocity", self.DEFAULT_PULSE_VELOCITY)
+ self.intensity_range = kw.pop(
+ "intensity_range", self.DEFAULT_INTENSITY_RANGE)
+ self.intensity_velocity = kw.pop(
+ "intensity_velocity", self.DEFAULT_INTENSITY_VELOCITY)
+ super(PulsatingLamp, self).__init__(**kw)
+
+ def _update_range(self, value, velocity, value_range):
+ value += velocity
+ if value < value_range[0]:
+ value = value_range[0]
+ velocity = -velocity
+ elif value > value_range[1]:
+ value = value_range[1]
+ velocity = -velocity
+ return value, velocity
+
+ def tick(self):
+ self.ray_manager.max_radius, self.pulse_velocity = self._update_range(
+ self.ray_manager.max_radius, self.pulse_velocity, self.pulse_range)
+ self.intensity, self.intensity_velocity = self._update_range(
+ self.intensity, self.intensity_velocity, self.intensity_range)
+
+
+class SpotLight(BaseLight):
+
+ FITTING_IMG = "spotlight.png"
+
+ def __init__(self, **kw):
+ self.angular_velocity = kw.pop("angular_velocity", None)
+ super(SpotLight, self).__init__(**kw)
+
+ def fitting_image(self):
+ fitting_image = super(SpotLight, self).fitting_image()
+ rot_fitting_image = pygame.transform.rotozoom(
+ fitting_image, self.ray_manager.direction - 90, 1)
+
+ rot_rect = fitting_image.get_rect().copy()
+ rot_rect.center = rot_fitting_image.get_rect().center
+ rot_fitting_image = rot_fitting_image.subsurface(rot_rect).copy()
+
+ return rot_fitting_image
+
+ def tick(self):
+ if self.angular_velocity:
+ self.ray_manager.direction -= self.angular_velocity
+ self.ray_manager.update_shapes()