From: Simon Cross Date: Sun, 4 Sep 2016 20:39:29 +0000 (+0200) Subject: Add filter to obstacle shapes. X-Git-Tag: tabakrolletjie-v1.0.0~248 X-Git-Url: https://git.ctpug.org.za/?a=commitdiff_plain;h=acaa20518c279ace7be09da5e157130da6c8ba6a;p=tabakrolletjie.git Add filter to obstacle shapes. --- diff --git a/tabakrolletjie/obstacles.py b/tabakrolletjie/obstacles.py index d187a59..32df5b4 100644 --- a/tabakrolletjie/obstacles.py +++ b/tabakrolletjie/obstacles.py @@ -4,6 +4,10 @@ import pymunk import pymunk.pygame_util import pygame.draw +from .constants import OBSTACLE_CATEGORY + +OBSTACLE_FILTER = pymunk.ShapeFilter(categories=OBSTACLE_CATEGORY) + class BaseObstacle(object): def __init__(self): @@ -13,6 +17,8 @@ class BaseObstacle(object): def add(self, space): if self.body.space is not None: space.remove(self.body, *self.body.shapes) + for shape in self.shapes: + shape.filter = OBSTACLE_FILTER space.add(self.body, *self.shapes) def render(self, surface):