From acaa20518c279ace7be09da5e157130da6c8ba6a Mon Sep 17 00:00:00 2001 From: Simon Cross Date: Sun, 4 Sep 2016 22:39:29 +0200 Subject: [PATCH] Add filter to obstacle shapes. --- tabakrolletjie/obstacles.py | 6 ++++++ 1 file changed, 6 insertions(+) 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): -- 2.34.1