Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def checkCollision(minX1, maxX1, minY1, maxY1, minX2, maxX2, minY2, maxY2):
- """
- This function checks if two objects collide. Every parameter with a 1 is for the first object, and every parameter
- with a 2 is for the second object. The minimum X value (minX) is for the lowest X value of the object. The maximum
- X value (maxX) is for the highest X value of the object. The minimum Y value (minY) is for the lowest Y value of
- the object. The maximum Y value (maxY) is for the highest Y value of the object.
- The function checks if the minimum or maximum X value of object 1 is within the minimum and maximum X value of
- object 2, and also if the minimum or maximum Y value of object 2 is within the minimum and maximum Y value of
- object 1. It returns a boolean of whether or not the objects have collided (basically if the conditions above are
- true or false).
- :param minX1:
- :param maxX1:
- :param minY1:
- :param maxY1:
- :param minX2:
- :param maxX2:
- :param minY2:
- :param maxY2:
- :return:
- """
- return (minX2 <= minX1 <= maxX2 or minX2 <= maxX1 <= maxX2) and (minY1 <= minY2 <= maxY1 or minY1 <= maxY2 <= maxY1)
Add Comment
Please, Sign In to add comment