rayflap

A Flappy Bird clone written in C and compiled to WebAssembly.
git clone https://unitehenry.com/git/rayflap.git
Log | Files | Refs | README

commit 024cd391bdace50f64feca640652969c3950c9e8
parent 55fe093b545fd408be38c4cafdd061c3790dc8ce
Author: Henry Unite <unitehenry@gmail.com>
Date:   Sun, 19 Apr 2026 17:31:34 +0000

feat: load score textures

Diffstat:
Msrc/game.c | 25+++++++++++++++++++++++++
1 file changed, 25 insertions(+), 0 deletions(-)

diff --git a/src/game.c b/src/game.c @@ -20,6 +20,7 @@ Texture2D messageTexture; Texture2D birdTexture; Texture2D baseTexture; Texture2D pipeTexture; +Texture2D scoreTexture[10]; /* Game State */ typedef enum { TITLE, PLAY } Screen; @@ -186,6 +187,28 @@ void draw_base() { DrawTexturePro(baseTexture, source, baseRect2, origin, 0.0f, WHITE); } +void draw_score() { + if (screen == TITLE) { + return; + } + + if (!IsTextureValid(scoreTexture[0])) { + for (int i = 0; i < sizeof(scoreTexture) / sizeof(scoreTexture[0]); i++) { + char *texturePath; + + asprintf(&texturePath, "assets/sprites/%i.png", i); + + scoreTexture[i] = LoadTexture(texturePath); + } + } + + float centerX = (screenWidth - scoreTexture[0].width) / 2.0f; + + float centerY = (screenHeight - scoreTexture[0].height) / 2.0f; + + DrawTexture(scoreTexture[0], centerX, centerY, WHITE); +} + void draw() { BeginDrawing(); @@ -204,6 +227,8 @@ void draw() { draw_bird(); + draw_score(); + EndDrawing(); }