Ok, so I implemented the bounding box collision system and it works, but I want to split it up so that I can tell whether the ball collides with the top or bottom half of the paddle. This is the boundingboxtest function, how can i modify it to check if it's colliding with the top or bottom half?
int boundingBoxTest(const sf::RectangleShape& object1, const sf::RectangleShape& object2)
{
// 0 = not colliding
// 1 = colliding with top
// 2 = colliding with bottom
BoundingBox obj1 = object1;
BoundingBox obj2 = object2;
// Create the four distinct axes that are perpindicular to the edjes of the two rectangles
sf::Vector2f axes[4] =
{
sf::Vector2f(obj1.points[1].x - obj1.points[0].x, obj1.points[1].y - obj1.points[0].y),
sf::Vector2f(obj1.points[1].x - obj1.points[2].x, obj1.points[1].y - obj1.points[2].y),
sf::Vector2f(obj2.points[0].x - obj2.points[3].x, obj2.points[0].y - obj2.points[3].y),
sf::Vector2f(obj2.points[0].x - obj2.points[1].x, obj2.points[0].y - obj2.points[1].x)
};
for (int i = 0; i < 4; i++)
{
float minOBJ1, maxOBJ1, minOBJ2, maxOBJ2;
obj1.projectOntoAxis(axes[i], minOBJ1, maxOBJ1);
obj2.projectOntoAxis(axes[i], minOBJ2, maxOBJ2);
if (!((minOBJ2 <= maxOBJ1) && (maxOBJ2 >= minOBJ1)))
return 0;
}
return 1;
}