Guest User

Untitled

a guest
Jun 20th, 2018
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.15 KB | None | 0 0
  1. def checkCollision(minX1, maxX1, minY1, maxY1, minX2, maxX2, minY2, maxY2):
  2. """
  3. This function checks if two objects collide. Every parameter with a 1 is for the first object, and every parameter
  4. with a 2 is for the second object. The minimum X value (minX) is for the lowest X value of the object. The maximum
  5. X value (maxX) is for the highest X value of the object. The minimum Y value (minY) is for the lowest Y value of
  6. the object. The maximum Y value (maxY) is for the highest Y value of the object.
  7.  
  8. The function checks if the minimum or maximum X value of object 1 is within the minimum and maximum X value of
  9. object 2, and also if the minimum or maximum Y value of object 2 is within the minimum and maximum Y value of
  10. object 1. It returns a boolean of whether or not the objects have collided (basically if the conditions above are
  11. true or false).
  12. :param minX1:
  13. :param maxX1:
  14. :param minY1:
  15. :param maxY1:
  16. :param minX2:
  17. :param maxX2:
  18. :param minY2:
  19. :param maxY2:
  20. :return:
  21. """
  22. return (minX2 <= minX1 <= maxX2 or minX2 <= maxX1 <= maxX2) and (minY1 <= minY2 <= maxY1 or minY1 <= maxY2 <= maxY1)
Add Comment
Please, Sign In to add comment