diff --git a/breakout/breakout.c b/breakout/breakout.c index a887791..4098d9f 100644 --- a/breakout/breakout.c +++ b/breakout/breakout.c @@ -290,9 +290,9 @@ void updateBall(Uint32 tickrate, ball *theBall, paddle *thePaddle, int winWidth, double paddleRX = thePaddle->x - (double)(winWidth / 2); double paddleRY = 20 - (double)(winHeight / 2); - if (ballNX > paddleRX && ballNYwidth && // ...and to the left of the right side of the paddle (i.e. about to go inside inside the paddle) - ballNY > (paddleRY-thePaddle->height)) { // ...and above the bottom of the paddle + if (ballNX+theBall->radius > paddleRX && ballNY-theBall->radius < paddleRY && // If to the right and below the top left corner of paddle + ballNX-theBall->radius < paddleRX + (double)thePaddle->width && // ...and to the left of the right side of the paddle + ballNY > (paddleRY-thePaddle->height)) { // ...and above the bottom of the paddle (all now compensating for ball radius) theBall->vY *= -1.0; theBall->vX = ((ballNX - paddleRX - (double)(thePaddle->width/2))/((double)thePaddle->width/2))*0.5; // Sets X velocity to be proportional to the relative position of the ball and the paddle on collision } diff --git a/breakout/makefile b/breakout/makefile index 6e9dd26..c438a9a 100644 --- a/breakout/makefile +++ b/breakout/makefile @@ -2,3 +2,4 @@ breakout_s = breakout.c breakout_c = breakout all: breakout.c clang $(breakout_s) -l SDL2 -lGLU -lGL -o $(breakout_c) + ./breakout