changeset 401:55e00f186c6f

imported patch floor_checks
author Neil Muller <drnlmuller@gmail.com>
date Sat, 09 Apr 2011 16:53:38 +0200
parents 1501d9b7f5dd
children a13d541b9e24
files skaapsteker/physics.py
diffstat 1 files changed, 8 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/skaapsteker/physics.py	Sat Apr 09 16:50:54 2011 +0200
+++ b/skaapsteker/physics.py	Sat Apr 09 16:53:38 2011 +0200
@@ -100,6 +100,10 @@
     def collided(self, other):
         pass
 
+    def check_floors(self, floors):
+        """Trigger of the current set of floors"""
+        pass
+
     def apply_friction(self):
         v_x, v_y = self.velocity
         self.velocity = self.friction_coeff[0] * v_x, self.friction_coeff[1] * v_y
@@ -275,20 +279,22 @@
                     (sprite.collide_rect.left, sprite.collide_rect.bottom),
                     (sprite.collide_rect.width, 1))
             collides = contact_rect.colliderect
+            floors = []
             if sprite.on_solid:
                 # Check if we are still in contact with the ground
                 still_on_solid = False
                 for other in self._collision_groups[sprite.collision_layer]:
                     if (other.floor or other.block) and collides(other.floor_rect):
                         still_on_solid = True
-                        break
+                        floors.append(other)
                 sprite.on_solid = still_on_solid
             else:
                 # Are we currently in contact with the ground
                 for other in self._collision_groups[sprite.collision_layer]:
                     if (other.floor or other.block) and collides(other.floor_rect):
                         sprite.on_solid = True
-                        break
+                        floors.append(other)
+            sprite.check_floors(floors)
 
         # call update methods
         self._updaters.update()