I’m making my very own recreation engine on Python and I bought caught with collision between objects.
# If we go Proper if (collision_rect.proper >= object_collision_rect.left) and (collision_rect.left <= object_collision_rect.left): if (collision_rect.backside > object_collision_rect.high) and (collision_rect.high < object_collision_rect.backside): if self.acceleration.x > 0: self.acceleration.x = 0 shifting.x = object_collision_rect.left - collision_rect.proper # Backside if (collision_rect.backside >= object_collision_rect.high) and (collision_rect.high <= object_collision_rect.high): if (collision_rect.proper > object_collision_rect.left) and (collision_rect.left < object_collision_rect.proper): if self.acceleration.y > 0: self.acceleration.y = 0 shifting.y = object_collision_rect.high - collision_rect.backside
There are two extra for left and high.
It makes teleporting on corners. And if we alter the second situations from < > to <= >=, we get teleporting on edges, if we have now acceleration x and y each != 0