1
Graphics / Check collisions on certain part sf::RectangleShape
« on: October 14, 2022, 08:42:44 pm »
Hey all,
I'm currently making an Arkanoid clone and I would like to change the direction of the ball depending on where the ball has touched the paddle. Previously, had it working with getGlobalBounds and intersects below:
This is good and gets the basic bounce working but I would like to take it a step further. I would like to know where exactly the ball has intersected the paddle so I can do some different stuff with ball speed and direction.
My question is: How can I check where exactly a collision happened on a sf::RectangleShape?
Thanks!
I'm currently making an Arkanoid clone and I would like to change the direction of the ball depending on where the ball has touched the paddle. Previously, had it working with getGlobalBounds and intersects below:
if (this->ball.getGlobalBounds().intersects(this->player))
{
// Do stuff
}
{
// Do stuff
}
This is good and gets the basic bounce working but I would like to take it a step further. I would like to know where exactly the ball has intersected the paddle so I can do some different stuff with ball speed and direction.
My question is: How can I check where exactly a collision happened on a sf::RectangleShape?
Thanks!