I am making my own game engine on Python and I got stuck with collision between objects.
# If we go Right if (collision_rect.right >= object_collision_rect.left) and \ (collision_rect.left <= object_collision_rect.left): if (collision_rect.bottom > object_collision_rect.top) and \ (collision_rect.top < object_collision_rect.bottom): if self.acceleration.x > 0: self.acceleration.x = 0 moving.x = object_collision_rect.left - collision_rect.right # Bottom if (collision_rect.bottom >= object_collision_rect.top) and \ (collision_rect.top <= object_collision_rect.top): if (collision_rect.right > object_collision_rect.left) and \ (collision_rect.left < object_collision_rect.right): if self.acceleration.y > 0: self.acceleration.y = 0 moving.y = object_collision_rect.top - collision_rect.bottom
There are two more for left and top.
It makes teleporting on corners. And if we change the second conditions from < > to <= >=, we get teleporting on edges, if we have acceleration x and y both != 0