WIP Background
This commit is contained in:
parent
34e8e7421a
commit
aaf5e45824
@ -1,5 +1,6 @@
|
||||
#include <raylib.h>
|
||||
|
||||
Color ColorLerp(Color c1, Color c2, float amount);
|
||||
Color ColorAdd(Color c, int add);
|
||||
Vector2 CalculateVector(float rotation, float offSet, float len);
|
||||
float GetRandomFloat();
|
@ -27,6 +27,8 @@ private:
|
||||
RandBuffer starBuff;
|
||||
RandBuffer mountenBuff;
|
||||
Moon m_moon;
|
||||
int colorSet;
|
||||
int time;
|
||||
|
||||
int size = 0;
|
||||
|
||||
|
@ -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;
|
||||
};
|
||||
|
11
src/Math.cpp
11
src/Math.cpp
@ -1,4 +1,6 @@
|
||||
#include <cmath>
|
||||
#include <algorithm>
|
||||
|
||||
#include "Math.hpp"
|
||||
#include <raymath.h>
|
||||
|
||||
@ -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;
|
||||
|
@ -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()
|
||||
|
@ -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];
|
||||
}
|
25
src/values/MyRand.cpp
Normal file
25
src/values/MyRand.cpp
Normal file
@ -0,0 +1,25 @@
|
||||
#include <inttypes.h>
|
||||
|
||||
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;
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user