Hi,
in school we are making a Pong Game. I only have a problem with the bouncing when the ball touches the paddle on one of the edges the ball gets stuck in the paddle.
Bounce Method:
void testCollision(Ball ball) {
if (x < ball.getX() + ball.getRadius() &&
x + playerWidth > ball.getX() - ball.getRadius() &&
y < ball.getY()&&
y + playerHeight > ball.getY()) {
ball.bounceX();
} else if (y < ball.getY() - ball.getY()&&
y + playerHeight > ball.getY() + ball.getY()&&
x < ball.getX() + ball.getRadius() &&
x + playerWidth > ball.getX() - ball.getRadius()) {
ball.bounceY();
}
}
Sorry for the format i couldn't make it cleaner looking. I would take advices for it.
If someone needs more code from the game i could give it to you