Draft of adding lights to a space.
authorSimon Cross <hodgestar@gmail.com>
Sun, 4 Sep 2016 17:08:52 +0000 (19:08 +0200)
committerSimon Cross <hodgestar@gmail.com>
Sun, 4 Sep 2016 17:08:52 +0000 (19:08 +0200)
tabakrolletjie/lights.py

index 8ec89a0cb37ac07bbb4f7ddab57e227b91ce5afd..92b66e0a8d4b91907fdec632724e00b0ffa9fba8 100644 (file)
@@ -1,14 +1,26 @@
 """ May it be a light for you in dark places, when all other lights go out.
 """
 
+import pymunk
+
 
 class BaseLight(object):
     """ Common light functionality. """
 
     def __init__(self, colour, position):
+        self.body = pymunk.Body(0, 0, pymunk.body.Body.STATIC)
         self.colour = colour
         self.position = position
 
+    def add_to_space(self, space):
+        space.remove(self.body, **self.body.shapes())
+        shapes = self.determine_ray_polys(space)
+        space.add(self.body, **shapes)
+
+    def determine_ray_polys(self, space):
+        raise NotImplementedError(
+            "Lights should implement .determine_ray_polys.")
+
     @classmethod
     def load(cls, config):
         kw = config.copy()