Ejemplo n.º 1
0
 def testCollisionOther(self, body, bbox=None):
     if bbox is None:
         bbox = body.bbox
     for other in (b for b in self.bodies if b is not body):
         if bbox.collidebbox(other.bbox):
             return True
     return False
Ejemplo n.º 2
0
        # test for collision with level geometry
        if self.testCollision(body.bbox):
            if body.bbox[2] < -10:
                body.bbox[2] = -10.0
                body.bbox.move(-x, -y, 0)
            else:
                body.bbox.move(-x, -y, -z)
            return False

        else:
            # test for collision with another object
            # must do a spatial hash or oct tree or something here [later]
            bbox = body.bbox
            for other in (b for b in self.bodies if b is not body):
                if bbox.collidebbox(other.bbox):
                    if self.moveBody(other, (x, y, z)):
                        return True
                    else:
                        body.bbox.move(-x, -y, -z)
                        return False

        return True


    def testCollisionOther(self, body, bbox=None):
        if bbox is None:
            bbox = body.bbox
        for other in (b for b in self.bodies if b is not body):
            if bbox.collidebbox(other.bbox):
                return True