8 #ifndef COLLISIONSUTILS_HPP_
9 #define COLLISIONSUTILS_HPP_
19 T pos1X = pos1.
x + rect1.
left;
20 T pos1Y = pos1.
y + rect1.
top;
21 T pos2X = pos2.
x + rect2.
left;
22 T pos2Y = pos2.
y + rect2.
top;
23 T x1 = std::max(pos1X, pos2X);
24 T y1 = std::max(pos1Y, pos2Y);
25 T x2 = std::min(pos1X + rect1.
width, pos2X + rect2.
width);
29 T diffX = center.
x - rectCenter.
x;
30 T diffY = center.
y - rectCenter.
y;
31 if (x2 - x1 > y2 - y1) {
class representing a rect
Definition: Rect.hpp:25
T height
Definition: Rect.hpp:40
T top
Definition: Rect.hpp:38
T left
Definition: Rect.hpp:37
bool isColliding(const Vector2< T > &pos, const Rect< T > &rect, const Vector2< T > &rectPos) const
check the collision between two objects
Definition: Rect.hpp:51
T width
Definition: Rect.hpp:39
a Vector2 class
Definition: Vector.hpp:20
T y
Definition: Vector.hpp:101
T x
Definition: Vector.hpp:98
Definition: AssetManager.hpp:15
int replaceOnTop(Vector2< T > &pos1, const Rect< T > &rect1, const Vector2< T > &pos2, const Rect< T > &rect2)
Definition: CollisionsUtils.hpp:15