changeset 456:427d4a3c53d7

Better CollidePuzzler behaviour.
author Jeremy Thurgood <firxen@gmail.com>
date Sat, 07 Sep 2013 15:26:00 +0200
parents 249869caaaf3
children fcf9f6edf153
files nagslang/puzzle.py
diffstat 1 files changed, 11 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/nagslang/puzzle.py	Sat Sep 07 15:21:00 2013 +0200
+++ b/nagslang/puzzle.py	Sat Sep 07 15:26:00 2013 +0200
@@ -70,13 +70,21 @@
             collision_types = (COLLISION_TYPE_PLAYER,)
         self._collision_types = collision_types
 
-    def get_colliders(self):
+    def get_interior_colliders(self):
         space = self.game_object.get_space()
         my_shape = self.game_object.get_shape()
         shapes = [shape for shape in space.shapes
                   if shape.collision_type in self._collision_types]
-        return [shape for shape in shapes
-                if my_shape in space.point_query(shape.body.position)]
+        return set(shape for shape in shapes
+                   if my_shape in space.point_query(shape.body.position))
+
+    def get_colliders(self):
+        space = self.game_object.get_space()
+        my_shape = self.game_object.get_shape()
+        shapes = set(shape for shape in space.shape_query(my_shape)
+                     if shape.collision_type in self._collision_types)
+        shapes.update(self.get_interior_colliders())
+        return shapes
 
     def get_state(self):
         return bool(self.get_colliders())