commit b33fddeee28de88ac7a49e556d72b936a1be83c3
parent f311b1c63895263b84d4ddfad6bf52ba66c0e7f2
Author: Henry Unite <unitehenry@gmail.com>
Date: Sun, 19 Apr 2026 17:58:31 +0000
feat: count score
Diffstat:
1 file changed, 10 insertions(+), 0 deletions(-)
diff --git a/src/game.c b/src/game.c
@@ -33,6 +33,7 @@ char *birdColor = NULL;
float birdRotate = 0.0f;
float thrust = 0.0f;
float gravity = 0.0f;
+int lastCountedPipe = -1;
int score = 0;
/* Entities */
@@ -349,6 +350,8 @@ void reset() {
isPaused = false;
screen = TITLE;
birdColor = NULL;
+ lastCountedPipe = -1;
+ score = 0;
}
void input() {
@@ -409,6 +412,13 @@ void update() {
topPipeRect.width = (float)pipeTexture.width;
topPipeRect.height = (float)pipeTexture.height;
+ if (bottomPipeRect.x < (screenWidth / 2.0f)) {
+ if (lastCountedPipe != i) {
+ score++;
+ lastCountedPipe = i;
+ }
+ }
+
if (topPipeRect.x < offscreenX) {
Vector2 pipeY = random_pipe_y();