projects
/
tabakrolletjie.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
0714311
)
Hacky demonstration of changing angle limits.
author
Simon Cross
<hodgestar@gmail.com>
Wed, 7 Sep 2016 21:30:04 +0000
(23:30 +0200)
committer
Simon Cross
<hodgestar@gmail.com>
Wed, 7 Sep 2016 21:30:04 +0000
(23:30 +0200)
tabakrolletjie/lights.py
patch
|
blob
|
history
diff --git
a/tabakrolletjie/lights.py
b/tabakrolletjie/lights.py
index c143b98862326dc385658b53998934d45b7ff179..22f43586e44343c23c7481dc46df02098e7a3d1d 100644
(file)
--- a/
tabakrolletjie/lights.py
+++ b/
tabakrolletjie/lights.py
@@
-76,6
+76,10
@@
class LightManager(object):
for light in self._lights:
light.render_fitting(surface)
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. """
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)
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)
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))
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)
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)
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)