Welcome, Guest. Please login or register. Did you miss your activation email?

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - n3wt

Pages: [1]
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:

if (this->ball.getGlobalBounds().intersects(this->player))
{
        // 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!

Pages: [1]
anything