def query_collision ( collision_object ) : global collidable_objects # Note that we use a Brute Force approach for the time being. # It performs horribly under heavy loads, but it meets # our needs for the time being. for obj in collidable_objects : # Make sure we don't check ourself against ourself. if obj . obj_id is not collision_object . obj_id : if collision_object . is_colliding ( obj ) : # A collision has been detected. Return the object that we are colliding with. return obj # No collision was noticed. Return None. return None
python code for elastic collision of objects
Check to see if the specified object is colliding with any of the objects currently in the Collision Manager Returns the first object we are colliding with if there was a collision and None if no collisions was found
def query_collision(collision_object):
        """
        Check to see if the specified object is colliding with any of the objects currently in the Collision Manager
        Returns the first object we are colliding with if there was a collision and None if no collisions was found
        """
        global collidable_objects
        # Note that we use a Brute Force approach for the time being.
        # It performs horribly under heavy loads, but it meets
        # our needs for the time being.
        for obj in collidable_objects:
            # Make sure we don't check ourself against ourself.
            if obj.obj_id is not collision_object.obj_id:
                if collision_object.is_colliding(obj):
                    # A collision has been detected. Return the object that we are colliding with.
                    return obj

        # No collision was noticed. Return None.
        return None