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 5ebf09dc9236ee7e120b5d4e36fba66b4b795a0f
parent 968d0f776c228455f052c78e8d3189e9827b8e89
Author: Henry Unite <unitehenry@gmail.com>
Date:   Sun, 19 Apr 2026 17:09:27 +0000

feat: starting pipe y

Diffstat:
Msrc/game.c | 17++++++++++-------
1 file changed, 10 insertions(+), 7 deletions(-)

diff --git a/src/game.c b/src/game.c @@ -211,16 +211,23 @@ void reset_pipes() { if (!IsTextureValid(pipeTexture)) return; - float defaultY = (screenHeight / 2.0f + (pipeTexture.height / 6.0f)); + float unit = screenHeight / 20.0f; + + float lowerBound = pipeTexture.height - (unit * 5); + + float upperBound = screenHeight - pipeTexture.height + (unit * 8); for (int i = 0; i < sizeof(pipeRects) / sizeof(pipeRects[0]); i += 2) { float startX = i > 0 ? pipeRects[i - 1].x + screenWidth - pipeTexture.width : (screenWidth + pipeTexture.width); + // TODO: pick between lowerBound and upperBound + float pipeY = 192; + Rectangle bottomPipeRect = pipeRects[i]; bottomPipeRect.x = startX; - bottomPipeRect.y = defaultY; + bottomPipeRect.y = pipeY; bottomPipeRect.width = (float)pipeTexture.width; bottomPipeRect.height = (float)pipeTexture.height; @@ -229,7 +236,7 @@ void reset_pipes() { Rectangle topPipeRect = pipeRects[i + 1]; topPipeRect.x = startX; - topPipeRect.y = defaultY; + topPipeRect.y = pipeY - (unit * 4) - pipeTexture.height; topPipeRect.width = (float)pipeTexture.width; topPipeRect.height = (float)pipeTexture.height; @@ -325,8 +332,6 @@ void update() { float offscreenX = 0.0f - pipeTexture.width; - float defaultY = (screenHeight / 2.0f + (pipeTexture.height / 6.0f)); - int lastIdx = (sizeof(pipeRects) / sizeof(pipeRects[0])) - 1; for (int i = 0; i < sizeof(pipeRects) / sizeof(pipeRects[0]); i += 2) { @@ -336,7 +341,6 @@ void update() { Rectangle bottomPipeRect = pipeRects[i]; bottomPipeRect.x -= scrollSpeed; - bottomPipeRect.y = defaultY; bottomPipeRect.width = (float)pipeTexture.width; bottomPipeRect.height = (float)pipeTexture.height; @@ -349,7 +353,6 @@ void update() { Rectangle topPipeRect = pipeRects[i + 1]; topPipeRect.x -= scrollSpeed; - topPipeRect.y = defaultY - 420; topPipeRect.width = (float)pipeTexture.width; topPipeRect.height = (float)pipeTexture.height;