So was learning how to make a game with pygame in a tutorial and that game needed collision so they created pygame masks object but i did not get why to check the collision between two objects we need to find the distance between there x and y coordinate can someone explain me why we need the x and y coordinates distance between the two objects
Here is the code collision function:
def collide(obj1, obj2):
offset_x = obj2.x - obj1.x
offset_y = obj2.y - obj1.y
return obj1.mask.overlap(obj2.mask, (offset_x, offset_y)) != None # (x, y) it will return if collison else false
Can anyone explain me the logic how the mask system in pygame works and why we need offset_x
, offset_y