diff --git a/game.c b/game.c index 1f05b3d578265e95c6b4ed1eb09d0242918dc8d9..79d845f90ae55b74857d445a7211f6658b77aa6d 100644 --- a/game.c +++ b/game.c @@ -23,15 +23,24 @@ void UpdateBall(Ball *ball, Paddle *paddle) { ball->position.x += ball->speed.x; ball->position.y += ball->speed.y; - // Bounce off top and bottom walls - if (ball->position.y <= 0 || ball->position.y >= 450) { + // Bounce off top and bottom + if (ball->position.y <= 0 || ball->position.y + ball->radius >= 450) { ball->speed.y *= -1; } - // Ball hits paddle + // Bounce off paddle if (CheckCollisionCircleRec(ball->position, ball->radius, paddle->rect)) { ball->speed.x *= -1; ball->score++; + + // ✅ Level progression: increase speed every 5 points + if (ball->score % 5 == 0) { + if (ball->speed.x > 0) ball->speed.x += 1; + else ball->speed.x -= 1; + + if (ball->speed.y > 0) ball->speed.y += 1; + else ball->speed.y -= 1; + } } // Ball missed paddle @@ -39,6 +48,9 @@ void UpdateBall(Ball *ball, Paddle *paddle) { ball->lives--; ball->position = (Vector2){400, 225}; + // Reset to base speed + ball->speed = (Vector2){4, 4}; + if (ball->lives <= 0) { ball->isGameOver = true; } @@ -57,8 +69,3 @@ void DrawGame(Paddle *paddle, Ball *ball) { DrawText("Press ESC to quit", 300, 250, 20, DARKGRAY); } } - -void FreeGame(Paddle *paddle, Ball *ball) { - free(paddle); - free(ball); -}