From b51fb5f3aad9c19d1f10e7829d8b7265b5a83933 Mon Sep 17 00:00:00 2001
From: "Lalit2.Dangi@live.uwe.ac.uk" <lalit2.dangi@live.uwe.ac.uk>
Date: Fri, 4 Apr 2025 10:30:25 +0000
Subject: [PATCH] Edit game.c

---
 game.c | 23 +++++++++++++++--------
 1 file changed, 15 insertions(+), 8 deletions(-)

diff --git a/game.c b/game.c
index 1f05b3d..79d845f 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);
-}
-- 
GitLab