Clickable lights.
[tabakrolletjie.git] / tabakrolletjie / lights.py
index c5c72af0df43cb289f4528ea94fabb65c41b52ee..2590e310bc3247680ce13eef5f2bea7b1fdc7964 100644 (file)
@@ -75,11 +75,12 @@ class BaseLight(object):
     }
 
     def __init__(self, colour, position):
-        self.on = True
-        self.body = pymunk.Body(0, 0, pymunk.body.Body.STATIC)
-        self.fitting = pymunk.Circle(self.body, 5.0)
         self.colour = colour
         self.position = pymunk.Vec2d(position)
+        self.on = True
+        self.body = pymunk.Body(0, 0, pymunk.body.Body.STATIC)
+        self.fitting = pymunk.Circle(self.body, 10.0, self.position)
+        self.body.light = self
 
     @classmethod
     def load(cls, config):
@@ -125,10 +126,9 @@ class BaseLight(object):
         surface.blit(subsurface, (0, 0), None)
 
     def render_fittings(self, surface):
-        centre = self.position + self.fitting.offset
         pygame.draw.circle(
             surface, (255, 255, 0),
-            pymunk.pygame_util.to_pygame(centre, surface),
+            pymunk.pygame_util.to_pygame(self.fitting.offset, surface),
             int(self.fitting.radius))