Skip to content

Commit 42ff5b2

Browse files
committed
+ defined colors
1 parent d079308 commit 42ff5b2

File tree

4 files changed

+19
-3
lines changed

4 files changed

+19
-3
lines changed

proj-BirdEngine/src/containers/containers.h

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,20 @@ struct Size : public Vector2 { public: Size(int width = 0, int height = 0) : Vec
66
struct Position : public Vector2 { public: Position(int x = 0, int y = 0) : Vector2{ x, y } {} };
77
struct Direction : public Vector2 { public: Direction(int x = 0, int y = 0) : Vector2{ x, y } {} };
88
struct Rect { Size size; Position position; };
9-
struct Color { public: uint8_t r; uint8_t g; uint8_t b; uint8_t a; };
9+
struct Color {
10+
static constexpr Color RED() { return Color(255, 0, 0); }
11+
static constexpr Color GREEN() { return Color(0, 255, 0); }
12+
static constexpr Color BLUE() { return Color(0, 0, 255); }
13+
static constexpr Color BLACK() { return Color(0, 0, 0); }
14+
static constexpr Color WHITE() { return Color(255, 255, 255); }
15+
static constexpr Color BLUE_BIRD() { return Color(120, 200, 250); }
1016

17+
constexpr Color(uint8_t r, uint8_t g, uint8_t b, uint8_t a = 255)
18+
: r(r), g(g), b(b), a(a)
19+
{}
20+
21+
uint8_t r;
22+
uint8_t g;
23+
uint8_t b;
24+
uint8_t a;
25+
};

proj-BirdEngine/src/engine/bird-engine.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ struct BirdEngine::Impl {
1010
DeviceManager device_manager;
1111
UserInterface user_interface;
1212
Color default_renderer_draw_color = Color{ 255, 255, 255, 255 };
13-
Color background_color = Color{ 120, 200, 250, 255 };
13+
Color background_color = Color::BLUE_BIRD();
1414

1515
Impl() : device_manager(), user_interface() {}
1616
~Impl() = default;

proj-BirdEngine/src/engine/bird-engine.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#pragma once
22
#include <dll/export_def.h>
33
#include <device/device_init_data.h>
4+
#include <containers/containers.h>
45
#include <memory>
56

67
typedef enum {

proj-FlappyBird/src/main.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ void setup_window() {
1919
int pos_y = display_size.y / 2 - height / 2 + offset_y;
2020
WindowRect r{ Size{width, height}, Position{pos_x, pos_y} };
2121
BirdEngine::instance().set_window_rect(r);
22-
BirdEngine::instance().set_background_color(Color{120, 200, 250, 255});
22+
BirdEngine::instance().set_background_color(Color::BLUE_BIRD());
2323
}
2424

2525
bool init() {

0 commit comments

Comments
 (0)