From d3e2c30ed619c4ef152430f1750b292e22d74444 Mon Sep 17 00:00:00 2001 From: Simon Cross Date: Wed, 7 Sep 2016 23:30:04 +0200 Subject: [PATCH] Hacky demonstration of changing angle limits. --- tabakrolletjie/lights.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/tabakrolletjie/lights.py b/tabakrolletjie/lights.py index c143b98..22f4358 100644 --- a/tabakrolletjie/lights.py +++ b/tabakrolletjie/lights.py @@ -76,6 +76,10 @@ class LightManager(object): 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. """ @@ -119,6 +123,7 @@ class BaseLight(object): 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) @@ -188,9 +193,21 @@ class BaseLight(object): 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) -- 2.34.1