From bdeb4f943fc351daeec22b4ef71d551342dc5a01 Mon Sep 17 00:00:00 2001 From: nathan Date: Mon, 22 Dec 2025 03:26:45 -0700 Subject: Added backgrounds --- src/game.c | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) (limited to 'src/game.c') diff --git a/src/game.c b/src/game.c index 7dbe9e8..427c55d 100644 --- a/src/game.c +++ b/src/game.c @@ -98,6 +98,20 @@ void updateMainMenuScene(Game* game) ClearBackground(BLACK); } +void drawGameTexturedBackground(Texture texture) +{ + int screenWidth = GetRenderWidth(); + int screenHeight = GetRenderHeight(); + + for (int y = 0; y < screenHeight; y += texture.height) + { + for (int x = 0; x < screenWidth; x += texture.width) + { + DrawTexture(texture, x, y, WHITE); + } + } +} + void drawGameScreen(Game* game) { Texture texture = game->screen.render.texture; @@ -202,7 +216,7 @@ void updateGameScene(Game* game) } BeginTextureMode(game->screen.render); - ClearBackground(BLACK); + ClearBackground(PINK); BeginMode3D(game->player.camera); // Render skybox. @@ -218,7 +232,18 @@ void updateGameScene(Game* game) EndMode3D(); EndTextureMode(); - ClearBackground(BLACK); + // Draw background texture or color. + if (game->settings.useBackgroundTexture + && !FloatEquals(game->screen.destination.x, 0.0)) + { + AssetId backgroundTextureId = BACKGROUND1_TEXTURE + + game->settings.backgroundTextureNumber; + drawGameTexturedBackground(game->assets.textures[backgroundTextureId]); + } + else + { + ClearBackground(game->settings.backgroundColor); + } drawGameScreen(game); -- cgit v1.2.3