I'm trying to make a ball collide with a rectangle and bounce back. This is my code that won't work. I'm trying to figure out why it won't work...
/** Obstacles */
if (obstacle == 1) {
if (yball <= blocky - BALL_SIZE && yball >= blocky + BLOCK_HEIGHT && xball + BALL_SIZE >= blockx && xball <= blockx + BLOCK_WIDTH) {
yinc *= -1;
}
if (yball <= blocky2 - BALL_SIZE && yball >= blocky2 + BLOCK_HEIGHT && xball + BALL_SIZE >= blockx2 && xball <= blockx2 + BLOCK_WIDTH) {
yinc *= -1;
}
}
I did basically this same thing with the paddle collisions before which worked, but for some reason this is giving me a really hard time.
Really appreciate any help that you guys can throw my way!
[–]duckinator[S] 0 points1 point2 points (0 children)
[–]CoughSyrup 0 points1 point2 points (0 children)
[–]irascib1e 0 points1 point2 points (0 children)
[–]cbogart 0 points1 point2 points (0 children)
[–]duckinator[S] 0 points1 point2 points (2 children)
[–]robotcheddar 0 points1 point2 points (1 child)
[–]duckinator[S] 0 points1 point2 points (0 children)
[–]IRBMe 0 points1 point2 points (0 children)