aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorfschildt <florian.schildt@protonmail.com>2025-12-12 02:23:25 +0100
committerfschildt <florian.schildt@protonmail.com>2025-12-12 02:23:25 +0100
commit815c9a41d35b1c4984c99ddd99068d8f1334b3bc (patch)
tree9dcbe4314c918a1eebfbdf8dfc9236f99142e85c /src
parentef11873681a1eaf45f66a4c20cbc9863c4a19318 (diff)
snake: fix z-values, change food/snake colors
Diffstat (limited to 'src')
-rw-r--r--src/games/Game.hpp3
-rw-r--r--src/games/snake/Snake.cpp23
2 files changed, 15 insertions, 11 deletions
diff --git a/src/games/Game.hpp b/src/games/Game.hpp
index a97d26c..c75f586 100644
--- a/src/games/Game.hpp
+++ b/src/games/Game.hpp
@@ -28,8 +28,7 @@ public:
};
enum ZLayer {
- z_background = 0,
- z_layer1,
+ z_layer1 = 1,
z_layer2,
z_layer3,
z_text
diff --git a/src/games/snake/Snake.cpp b/src/games/snake/Snake.cpp
index bb81470..ef9b678 100644
--- a/src/games/snake/Snake.cpp
+++ b/src/games/snake/Snake.cpp
@@ -1,7 +1,9 @@
#include "games/snake/Snake.hpp"
+#include "games/Game.hpp"
#include "renderer/Renderer.hpp"
#include "common/defs.hpp"
+#include <cstdint>
#include <imgui.h>
@@ -233,9 +235,16 @@ Snake::Draw()
int32_t max_positions = ARRAY_COUNT(m_body_positions);
+ uint32_t z_bg = z_layer1;
+ uint32_t z_food = z_layer2;
+ uint32_t z_snake = z_layer3;
+
+ Color color_snake = {0.0f, 0.5f, 0.0f, 1.0f};
+ Color color_food = {0.5f, 0.0f, 0.0f, 1.0f};
+ Color color_bg = {0.0f, 0.0f, 0.0f, 1.0f};
+
/* draw map background */
- uint32_t z = 1;
V3F32 map_world_pos = {map_x, map_y};
V2F32 map_world_dim = {map_view_width, map_view_height};
Rectangle map_world_rect = {
@@ -244,8 +253,7 @@ Snake::Draw()
map_world_pos.x + map_world_dim.x,
map_world_pos.y + map_world_dim.y
};
- Color bg_color = {0.0f, 0.0f, 0.0f, 1.0f};
- g_renderer.PushRectangle(map_world_rect, bg_color, z);
+ g_renderer.PushRectangle(map_world_rect, color_bg, z_bg);
/* draw snake */
@@ -273,8 +281,7 @@ Snake::Draw()
world_pos.y + world_dim.y,
};
- Color color = {0.3f, 0.3f, 0.3f, 1.0f};
- g_renderer.PushRectangle(world_rect, color, z);
+ g_renderer.PushRectangle(world_rect, color_snake, z_snake);
tail++;
}
tail = 0;
@@ -301,8 +308,7 @@ Snake::Draw()
world_pos.y + world_dim.y,
};
- Color color = {0.3f, 0.3f, 0.3f, 1.0f};
- g_renderer.PushRectangle(world_rect, color, z);
+ g_renderer.PushRectangle(world_rect, color_snake, z_snake);
tail++;
}
@@ -319,7 +325,6 @@ Snake::Draw()
pos.x + dim.x,
pos.y + dim.y
};
- Color color = {0.3f, 0.6f, 0.4f, 1.0f};
- g_renderer.PushRectangle(rect, color, z);
+ g_renderer.PushRectangle(rect, color_food, z_food);
}