for light in self._lights:
light.render_fitting(surface)
+ def tick(self):
+ for light in self._lights:
+ light.tick()
+
class BaseLight(object):
""" Common light functionality. """
if self.body.space is not None:
space.remove(self.body, *self.body.shapes)
self.ray_manager.generate_rays(space, self.position)
+ self.ray_manager.set_angle_limits(self.angle_limits)
ray_shapes = self.ray_manager.polys()
space.add(self.body, self.fitting, *ray_shapes)
pymunk.pygame_util.to_pygame(self.fitting.offset, surface),
int(self.fitting.radius))
+ def tick(self):
+ pass
+
class SpotLight(BaseLight):
def __init__(self, **kw):
kw.pop("direction", None)
kw.pop("spread", None)
+ self.angular_velocity = kw.pop("angular_velocity", None)
super(SpotLight, self).__init__(**kw)
+
+ def tick(self):
+ if self.angular_velocity:
+ start, end = self.angle_limits
+ start = (start + self.angular_velocity) % 360.0
+ end = (end + self.angular_velocity) % 360.0
+ self.angle_limits = (start, end)
+ self.ray_manager.set_angle_limits(self.angle_limits)