From: Simon Cross Date: Sun, 4 Sep 2016 17:08:52 +0000 (+0200) Subject: Draft of adding lights to a space. X-Git-Tag: tabakrolletjie-v1.0.0~253 X-Git-Url: https://git.ctpug.org.za/?a=commitdiff_plain;h=d4d66b09aeef6f9973b15e8cc6d04883a9f6f339;p=tabakrolletjie.git Draft of adding lights to a space. --- diff --git a/tabakrolletjie/lights.py b/tabakrolletjie/lights.py index 8ec89a0..92b66e0 100644 --- a/tabakrolletjie/lights.py +++ b/tabakrolletjie/lights.py @@ -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()