changeset 192:3dc2b6290e66

Document collision handler a little better.
author Jeremy Thurgood <firxen@gmail.com>
date Tue, 03 Sep 2013 21:16:22 +0200
parents e080fcd07fa9
children d862cc209de4
files nagslang/game_object.py nagslang/screens/area.py
diffstat 2 files changed, 4 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/nagslang/game_object.py	Tue Sep 03 21:47:24 2013 +0200
+++ b/nagslang/game_object.py	Tue Sep 03 21:16:22 2013 +0200
@@ -386,7 +386,7 @@
         You can return `False` to ignore the collision, anything else
         (including `None`) to process the collision as normal.
         """
-        pass
+        return True
 
 
 class FloorSwitch(GameObject):
--- a/nagslang/screens/area.py	Tue Sep 03 21:47:24 2013 +0200
+++ b/nagslang/screens/area.py	Tue Sep 03 21:16:22 2013 +0200
@@ -84,6 +84,9 @@
     def _collision_pre_solve_handler(self, space, arbiter):
         gobj = arbiter.shapes[1].physicser.game_object
         result = gobj.collide_with_protagonist()
+        # The collision handler must return `True` or `False`. We don't want to
+        # accidentally reject collisions from handlers that return `None`, so
+        # we explicitly check for `False` and treate everything else as `True`.
         if result is False:
             return False
         return True