X-Git-Url: https://git.ctpug.org.za/?a=blobdiff_plain;f=tabakrolletjie%2Flights.py;h=2c691fefa9b508b53a07872eadff5702fff1e8f9;hb=9f403d319ac457967248b17a8f3c0de945bdc613;hp=b22bc35a61e2644766a19656cd4bce6a13131c1f;hpb=31c09587e13f51773b8788c2b2579cd05c67a486;p=tabakrolletjie.git diff --git a/tabakrolletjie/lights.py b/tabakrolletjie/lights.py index b22bc35..2c691fe 100644 --- a/tabakrolletjie/lights.py +++ b/tabakrolletjie/lights.py @@ -20,6 +20,9 @@ FITTINGS_FILTER = pymunk.ShapeFilter( LIGHT_CATEGORY | FITTINGS_CATEGORY), categories=FITTINGS_CATEGORY) +# Just match lights, nothing else +LIT_BY_FILTER = pymunk.ShapeFilter(mask=LIGHT_CATEGORY) + def screen_rays(pos): """ An iterable that returns ordered rays from pos to the edge of the @@ -98,6 +101,16 @@ class LightManager(object): lights = [p.shape.body.light for p in point_info_list] return [light for light in lights if light.on] + def light_query(self, shape): + """Query the lights by shape""" + old_filter = shape.filter + # We need to restrict matches to only the lights + shape.filter = LIT_BY_FILTER + shape_info_list = self._space.shape_query(shape) + shape.filter = old_filter + lights = [p.shape.body.light for p in shape_info_list] + return [light for light in lights if light.on] + def render_light(self, surface): for light in self._lights: light.render_light(surface)