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 c318e679fa5029891e3e46af492e627e1aa08862
parent 2deb384a32345649f789ff549e44ba78bdb3a362
Author: Henry Unite <unitehenry@gmail.com>
Date:   Sun, 19 Apr 2026 01:03:42 +0000

feat: random bird colors

Diffstat:
Msrc/game.c | 17++++++++++++++++-
1 file changed, 16 insertions(+), 1 deletion(-)

diff --git a/src/game.c b/src/game.c @@ -2,6 +2,7 @@ #include <emscripten/emscripten.h> #include <math.h> #include <stdio.h> +#include <time.h> #define MainLoop emscripten_set_main_loop @@ -21,6 +22,7 @@ typedef enum { TITLE, PLAY } Screen; Screen screen = TITLE; float backgroundScroll = 0.0f; float baseScroll = 0.0f; +char* birdColor = NULL; void draw_message() { if (screen != TITLE) @@ -55,8 +57,18 @@ void draw_background() { } void draw_bird() { + if (birdColor == NULL) { + char *birdColors[3] = { "red", "blue", "yellow" }; + + birdColor = birdColors[rand() % (sizeof(birdColors) / sizeof(birdColors[0]))]; + } + if (!IsTextureValid(birdTexture)) { - birdTexture = LoadTexture("assets/sprites/redbird-downflap.png"); + char *texturePath; + + asprintf(&texturePath, "assets/sprites/%sbird-downflap.png", birdColor); + + birdTexture = LoadTexture(texturePath); } float centerX = (screenWidth - birdTexture.width) / 2.0f; @@ -107,6 +119,9 @@ void draw(void) { } int main() { + // seed random + srand(time(NULL)); + InitWindow(screenWidth, screenHeight, title); MainLoop(draw, 60, 1);