From 178df0c1aeb419ebedf9db25c599d5e92e564542 Mon Sep 17 00:00:00 2001 From: Simon Cross Date: Wed, 7 Sep 2016 22:11:27 +0200 Subject: [PATCH] Fetch pygame polys from ray manager. --- tabakrolletjie/lights.py | 7 +------ tabakrolletjie/rays.py | 9 +++++++++ 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/tabakrolletjie/lights.py b/tabakrolletjie/lights.py index 39b1815..c143b98 100644 --- a/tabakrolletjie/lights.py +++ b/tabakrolletjie/lights.py @@ -155,12 +155,7 @@ class BaseLight(object): white, black = (255, 255, 255), (0, 0, 0) ray_mask.fill(black) - for shape in self.body.shapes: - if shape is self.fitting: - continue - pygame_poly = [ - pymunk.pygame_util.to_pygame(v, surface) for v in - shape.get_vertices()] + for pygame_poly in self.ray_manager.pygame_polys(surface): pygame.draw.polygon(ray_mask, white, pygame_poly, 0) pygame.draw.aalines(ray_mask, white, True, pygame_poly, 1) diff --git a/tabakrolletjie/rays.py b/tabakrolletjie/rays.py index d6d0a69..f7e69cc 100644 --- a/tabakrolletjie/rays.py +++ b/tabakrolletjie/rays.py @@ -67,6 +67,9 @@ class RayPolyManager(object): def polys(self): return [rp.poly(self._body, self._ray_filter) for rp in self._rays] + def pygame_polys(self, surface): + return [rp.pygame_poly(surface) for rp in self._rays] + class RayPoly(object): def __init__(self, start, end, vertices): @@ -78,3 +81,9 @@ class RayPoly(object): shape = pymunk.Poly(body, self.vertices) shape.filter = filter return shape + + def pygame_poly(self, surface): + return [ + pymunk.pygame_util.to_pygame(v, surface) + for v in self.vertices + ] -- 2.34.1