aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authornathan <nathansmith@disroot.org>2025-12-22 10:26:45 +0000
committernathan <nathansmith@disroot.org>2025-12-22 10:26:45 +0000
commitbdeb4f943fc351daeec22b4ef71d551342dc5a01 (patch)
tree05b1187184c4a7719effe91c6022fd6671149344
parent08c502d813b11b1f9dd7b7143a0987454c76ea32 (diff)
downloadFindThings-bdeb4f943fc351daeec22b4ef71d551342dc5a01.tar.gz
FindThings-bdeb4f943fc351daeec22b4ef71d551342dc5a01.tar.bz2
FindThings-bdeb4f943fc351daeec22b4ef71d551342dc5a01.zip
Added backgrounds
-rw-r--r--assets/images/background1.pngbin0 -> 1440 bytes
-rw-r--r--assets/images/background2.pngbin0 -> 2475 bytes
-rw-r--r--assets/images/background3.pngbin0 -> 5191 bytes
-rw-r--r--assets/images/background4.pngbin0 -> 5793 bytes
-rw-r--r--src/assets.c6
-rw-r--r--src/assets.h8
-rw-r--r--src/game.c29
-rw-r--r--src/settings.c3
-rw-r--r--src/settings.h3
9 files changed, 44 insertions, 5 deletions
diff --git a/assets/images/background1.png b/assets/images/background1.png
new file mode 100644
index 0000000..594f6b3
--- /dev/null
+++ b/assets/images/background1.png
Binary files differ
diff --git a/assets/images/background2.png b/assets/images/background2.png
new file mode 100644
index 0000000..7367ad5
--- /dev/null
+++ b/assets/images/background2.png
Binary files differ
diff --git a/assets/images/background3.png b/assets/images/background3.png
new file mode 100644
index 0000000..0e0b6f9
--- /dev/null
+++ b/assets/images/background3.png
Binary files differ
diff --git a/assets/images/background4.png b/assets/images/background4.png
new file mode 100644
index 0000000..809f25f
--- /dev/null
+++ b/assets/images/background4.png
Binary files differ
diff --git a/src/assets.c b/src/assets.c
index ecb5ca0..eb5c888 100644
--- a/src/assets.c
+++ b/src/assets.c
@@ -15,7 +15,11 @@ const char textureAssetPaths[TEXTURE_ASSET_COUNT][FT_NAMEMAX] = {
"trash.png",
"medicalTrash.png",
"John.png",
- "Ron.png"
+ "Ron.png",
+ "background1.png",
+ "background2.png",
+ "background3.png",
+ "background4.png"
};
const char imageAssetPaths[IMAGE_ASSET_COUNT][FT_NAMEMAX] = {
diff --git a/src/assets.h b/src/assets.h
index 9f0c1a7..fb2b660 100644
--- a/src/assets.h
+++ b/src/assets.h
@@ -4,7 +4,7 @@
#ifndef ASSETS_H
#define ASSETS_H
-#define TEXTURE_ASSET_COUNT 15
+#define TEXTURE_ASSET_COUNT 19
#define IMAGE_ASSET_COUNT 1
#define SHADER_ASSET_COUNT 4
#define MODEL_ASSET_COUNT 4
@@ -32,7 +32,11 @@ enum {
TRASH_TEXTURE,
MEDICAL_TRASH_TEXTURE,
JOHN_TEXTURE,
- RON_TEXTURE
+ RON_TEXTURE,
+ BACKGROUND1_TEXTURE,
+ BACKGROUND2_TEXTURE,
+ BACKGROUND3_TEXTURE,
+ BACKGROUND4_TEXTURE
};
// Image asset ids.
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);
diff --git a/src/settings.c b/src/settings.c
index 2fdc29a..c047090 100644
--- a/src/settings.c
+++ b/src/settings.c
@@ -9,6 +9,9 @@ Settings defaultSettings()
.screenHeight = 447,
.fov = 90.0,
.showFPSDefault = true,
+ .backgroundColor = (Color){74, 42, 74, 255},
+ .useBackgroundTexture = true,
+ .backgroundTextureNumber = 0,
.edgeDetectionWidth = 80.0,
.edgeDetectionHeight = 60.0,
.edgeDetectionFactor = 0.11,
diff --git a/src/settings.h b/src/settings.h
index bed506d..b8ab5ee 100644
--- a/src/settings.h
+++ b/src/settings.h
@@ -15,6 +15,9 @@ typedef struct {
// Render.
float fov;
bool showFPSDefault;
+ Color backgroundColor;
+ bool useBackgroundTexture;
+ int backgroundTextureNumber;
// Edge detection.
float edgeDetectionWidth;