diff --git a/inc/Math.hpp b/inc/Math.hpp index 695d188..f583320 100644 --- a/inc/Math.hpp +++ b/inc/Math.hpp @@ -1,5 +1,6 @@ #include Color ColorLerp(Color c1, Color c2, float amount); +Color ColorAdd(Color c, int add); Vector2 CalculateVector(float rotation, float offSet, float len); float GetRandomFloat(); \ No newline at end of file diff --git a/inc/canvas/BackGround.hpp b/inc/canvas/BackGround.hpp index 2b0534c..e835f81 100644 --- a/inc/canvas/BackGround.hpp +++ b/inc/canvas/BackGround.hpp @@ -27,6 +27,8 @@ private: RandBuffer starBuff; RandBuffer mountenBuff; Moon m_moon; + int colorSet; + int time; int size = 0; diff --git a/inc/canvas/BackGroundColors.hpp b/inc/canvas/BackGroundColors.hpp index e6efd23..f0a8f29 100644 --- a/inc/canvas/BackGroundColors.hpp +++ b/inc/canvas/BackGroundColors.hpp @@ -3,18 +3,12 @@ class BackGroundColors { public: - enum class ColorSet - { - night, - day1, - day2, - day3 - }; - - static void setColor(ColorSet color); + static void setColor(int color, int time); static Color backGroundColor; - static Color moonColor; - static Color backMountenColor; - static Color frontMountenColor; + + static Color MountenColor1; + static Color MountenColor2; + static Color MountenColor3; + constexpr static Color moonColor = {240, 240, 190, 255}; constexpr static Color starColor = WHITE; }; diff --git a/src/Math.cpp b/src/Math.cpp index 4b3d6e5..7c6a877 100644 --- a/src/Math.cpp +++ b/src/Math.cpp @@ -1,4 +1,6 @@ #include +#include + #include "Math.hpp" #include @@ -12,6 +14,15 @@ Color ColorLerp(Color c1, Color c2, float amount) return ret; } +Color ColorAdd(Color c, int add) +{ + int r = std::clamp(c.r + add, 0, 255); + int g = std::clamp(c.g + add, 0, 255); + int b = std::clamp(c.b + add, 0, 255); + + return {(unsigned char)r, (unsigned char)g, (unsigned char)b, c.a}; +} + Vector2 CalculateVector(float rotation, float offSet, float len) { float angle = ((rotation)*PI) / 180.0f; diff --git a/src/canvas/BackGround.cpp b/src/canvas/BackGround.cpp index 5b62248..60ac83d 100644 --- a/src/canvas/BackGround.cpp +++ b/src/canvas/BackGround.cpp @@ -17,20 +17,30 @@ void BackGround::newGen() starBuff.reset(); mountenBuff.reset(); m_moon = {GetRandomFloat(), GetRandomFloat(), GetRandomFloat()}; + colorSet = GetRandomValue(0, 3); + time = floor(Remap(m_moon.y, 0, 1, 4, 0)); - BackGroundColors::setColor(BackGroundColors::ColorSet::night); + BackGroundColors::setColor(colorSet, time); draw(); } void BackGround::draw() { - ClearBackground(BackGroundColors::backGroundColor); - drawStarts(); + if (colorSet == 3) + { + ClearBackground(BackGroundColors::backGroundColor); + drawStarts(); + } + else + { + DrawRectangleGradientV(0, 0, size, size, ColorAdd(BackGroundColors::backGroundColor, 60), BackGroundColors::backGroundColor); + } + drawMoon(); - drawMounten(20, (int)(mounten1min * size), (int)(mounten1max * size), BackGroundColors::backMountenColor); - drawMounten(21, (int)(mounten2min * size), (int)(mounten2max * size), ColorLerp(BackGroundColors::backMountenColor, BackGroundColors::frontMountenColor, colorRatio1)); - drawMounten(23, (int)(mounten3min * size), (int)(mounten3max * size), ColorLerp(BackGroundColors::backMountenColor, BackGroundColors::frontMountenColor, colorRatio2)); + drawMounten(20, (int)(mounten1min * size), (int)(mounten1max * size), BackGroundColors::MountenColor1); + drawMounten(21, (int)(mounten2min * size), (int)(mounten2max * size), BackGroundColors::MountenColor2); + drawMounten(23, (int)(mounten3min * size), (int)(mounten3max * size), BackGroundColors::MountenColor3); } void BackGround::drawStarts() diff --git a/src/canvas/BackGroundColors.cpp b/src/canvas/BackGroundColors.cpp index c858f64..09d9c34 100644 --- a/src/canvas/BackGroundColors.cpp +++ b/src/canvas/BackGroundColors.cpp @@ -1,37 +1,104 @@ #include "canvas/BackGroundColors.hpp" Color BackGroundColors::backGroundColor; -Color BackGroundColors::moonColor; -Color BackGroundColors::backMountenColor; -Color BackGroundColors::frontMountenColor; +Color BackGroundColors::MountenColor1; +Color BackGroundColors::MountenColor2; +Color BackGroundColors::MountenColor3; -void BackGroundColors::setColor(ColorSet color) +void BackGroundColors::setColor(int color, int time) { - switch (color) + if (color == 3) { - case ColorSet::night: backGroundColor = {21, 34, 56, 255}; - moonColor = {240, 240, 190, 255}; - backMountenColor = {28, 28, 38, 255}; - frontMountenColor = {0, 0, 0, 255}; - break; - case ColorSet::day1: - backGroundColor = {21, 34, 56, 255}; - moonColor = {240, 240, 190, 255}; - backMountenColor = {28, 28, 38, 255}; - frontMountenColor = {0, 0, 0, 255}; - break; - case ColorSet::day2: - backGroundColor = {21, 34, 56, 255}; - moonColor = {240, 240, 190, 255}; - backMountenColor = {28, 28, 38, 255}; - frontMountenColor = {0, 0, 0, 255}; - break; - case ColorSet::day3: - backGroundColor = {21, 34, 56, 255}; - moonColor = {240, 240, 190, 255}; - backMountenColor = {28, 28, 38, 255}; - frontMountenColor = {0, 0, 0, 255}; - break; + MountenColor1 = {28, 28, 38, 255}; + MountenColor2 = {21, 21, 27, 255}; + MountenColor3 = {17, 17, 20, 255}; + return; } -} + + Color colors[3][4][4] = { + { + { + {90, 60, 60, 255}, + {118, 91, 91, 255}, + {154, 131, 131, 255}, + {193, 161, 161, 255}, + }, + { + {90, 60, 60, 255}, + {118, 91, 91, 255}, + {154, 131, 131, 255}, + {193, 161, 161, 255}, + }, + { + {70, 40, 40, 255}, + {98, 71, 71, 255}, + {134, 111, 111, 255}, + {173, 141, 141, 255}, + }, + { + {60, 30, 30, 255}, + {88, 61, 61, 255}, + {124, 101, 101, 255}, + {163, 131, 131, 255}, + }, + }, + { + { + {103, 88, 51, 255}, + {148, 127, 73, 255}, + {186, 159, 92, 255}, + {163, 154, 132, 255}, + }, + { + {103, 88, 51, 255}, + {148, 127, 73, 255}, + {186, 159, 92, 255}, + {163, 154, 132, 255}, + }, + { + {83, 68, 31, 255}, + {128, 107, 53, 255}, + {166, 139, 72, 255}, + {143, 134, 112, 255}, + }, + { + {73, 58, 21, 255}, + {118, 97, 43, 255}, + {156, 129, 62, 255}, + {133, 124, 102, 255}, + }, + }, + { + { + {77, 84, 99, 255}, + {104, 126, 144, 255}, + {152, 219, 206, 255}, + {213, 240, 235, 255}, + }, + { + {81, 58, 36, 255}, + {111, 98, 78, 255}, + {180, 148, 119, 255}, + {200, 165, 133, 255}, + }, + { + {67, 44, 22, 255}, + {97, 84, 64, 255}, + {166, 134, 105, 255}, + {186, 151, 119, 255}, + }, + { + {46, 23, 1, 255}, + {76, 63, 43, 255}, + {145, 113, 84, 255}, + {165, 130, 98, 255}, + }, + }, + }; + + backGroundColor = colors[color][0][time]; + MountenColor1 = colors[color][1][time]; + MountenColor2 = colors[color][2][time]; + MountenColor3 = colors[color][3][time]; +} \ No newline at end of file diff --git a/src/values/MyRand.cpp b/src/values/MyRand.cpp new file mode 100644 index 0000000..29df61b --- /dev/null +++ b/src/values/MyRand.cpp @@ -0,0 +1,25 @@ +#include + +static uint32_t rprand_state[4] = {0}; + +static inline uint32_t my_rotate_left(const uint32_t x, int k) +{ + return (x << k) | (x >> (32 - k)); +} + +uint32_t my_rprand_xoshiro(void) +{ + const uint32_t result = my_rotate_left(rprand_state[1] * 5, 7) * 9; + const uint32_t t = rprand_state[1] << 9; + + rprand_state[2] ^= rprand_state[0]; + rprand_state[3] ^= rprand_state[1]; + rprand_state[1] ^= rprand_state[2]; + rprand_state[0] ^= rprand_state[3]; + + rprand_state[2] ^= t; + + rprand_state[3] = my_rotate_left(rprand_state[3], 11); + + return result; +} \ No newline at end of file