diff --git a/game.c b/game.c index b2de0e49c3b36f028ea7035b27fd161a75a4d119..c6cc6e11cc4f56e41954e299fe323a5308d6cb44 100644 --- a/game.c +++ b/game.c @@ -15,6 +15,7 @@ Ball *CreateBall(float x, float y, int radius, float speedX, float speedY) { b->radius = radius; return b; } +b->score = 0; // ✅ Start score at 0 void UpdateBall(Ball *ball, Paddle *paddle) { ball->position.x += ball->speed.x; @@ -25,10 +26,11 @@ void UpdateBall(Ball *ball, Paddle *paddle) { } if (CheckCollisionCircleRec(ball->position, ball->radius, paddle->rect)) { - ball->speed.x *= -1; - } + ball->speed.x *= -1; + ball->score++; // ✅ Increase score when ball hits paddle } + void DrawGame(Paddle *paddle, Ball *ball) { DrawRectangleRec(paddle->rect, BLUE); DrawCircleV(ball->position, ball->radius, RED);