Add ratio for sun rings

This commit is contained in:
Nikola Petrov 2024-04-18 06:11:30 +02:00
parent 288186e515
commit 513874d61c
2 changed files with 36 additions and 20 deletions

View File

@ -27,8 +27,15 @@ private:
float minSizeOfMoon = 0.05f; float minSizeOfMoon = 0.05f;
float maxSizeOfMoon = 0.075f; float maxSizeOfMoon = 0.075f;
float maxYPosOfMoon = 0.75f; float maxYPosOfMoon = 0.75f;
float bigRingRatio = 0.5f;
float smallRingRatio = 0.25f;
float bigRingBlend = 0.02f;
float smallRingBlend = 0.05f;
Color mountenColor = {28, 28, 38, 255}; Color backMountenColor = {28, 28, 38, 255};
Color frontMountenColor = {0, 0, 0, 255};
float colorRatio1 = 0.3f;
float colorRatio2 = 0.5f;
float mounten1 = 0.6875f; float mounten1 = 0.6875f;
float mounten2 = 0.8125f; float mounten2 = 0.8125f;
float mounten3 = 0.9125; float mounten3 = 0.9125;

View File

@ -17,9 +17,9 @@ void BackGround::newGen()
ClearBackground(backGroundColor); ClearBackground(backGroundColor);
starts(); starts();
moon(); moon();
mounten(20, 0.3, (int)(mounten1 * size), (int)(mounten2 * size), mountenColor); mounten(20, 0.3, (int)(mounten1 * size), (int)(mounten2 * size), backMountenColor);
mounten(21, 0.3, (int)(mounten2 * size), (int)(mounten3 * size), ColorLerp(mountenColor, BLACK, 0.1f)); mounten(21, 0.3, (int)(mounten2 * size), (int)(mounten3 * size), ColorLerp(backMountenColor, frontMountenColor, colorRatio1));
mounten(23, 0.3, (int)(mounten3 * size), (int)(mounten4 * size), ColorLerp(mountenColor, BLACK, 0.3f)); mounten(23, 0.3, (int)(mounten3 * size), (int)(mounten4 * size), ColorLerp(backMountenColor, frontMountenColor, colorRatio2));
} }
void BackGround::starts() void BackGround::starts()
@ -28,6 +28,8 @@ void BackGround::starts()
rlBegin(RL_TRIANGLES); rlBegin(RL_TRIANGLES);
rlNormal3f(0.0f, 0.0f, 1.0f); rlNormal3f(0.0f, 0.0f, 1.0f);
bool star = true;
for (size_t i = 1; i <= numOfStarts; i++) for (size_t i = 1; i <= numOfStarts; i++)
{ {
int x = GetRandomValue(0, size); int x = GetRandomValue(0, size);
@ -38,14 +40,17 @@ void BackGround::starts()
Color color = ColorLerp(backGroundColor, starColor, alph); Color color = ColorLerp(backGroundColor, starColor, alph);
rlColor4ub(color.r, color.g, color.b, color.a); rlColor4ub(color.r, color.g, color.b, color.a);
if (star)
{
// topLeft // topLeft
rlVertex2f(x, y); rlVertex2f(x, y);
// bottomLeft // bottomLeft
rlVertex2f(x, y + weight); rlVertex2f(x, y + weight);
// topRight // topRight
rlVertex2f(x + weight, y); rlVertex2f(x + weight, y);
}
else
{
// bottomRight // bottomRight
rlVertex2f(x + weight, y + weight); rlVertex2f(x + weight, y + weight);
// topRight // topRight
@ -53,6 +58,8 @@ void BackGround::starts()
// bottomLeft // bottomLeft
rlVertex2f(x, y + weight); rlVertex2f(x, y + weight);
} }
star = !star;
}
rlEnd(); rlEnd();
rlSetTexture(0); rlSetTexture(0);
} }
@ -62,9 +69,11 @@ void BackGround::moon()
int xpos = GetRandomValue(100, size - 100); int xpos = GetRandomValue(100, size - 100);
int ypos = GetRandomValue(100, (int)(maxYPosOfMoon * size)); int ypos = GetRandomValue(100, (int)(maxYPosOfMoon * size));
int r = GetRandomValue((int)(minSizeOfMoon * size), (int)(maxSizeOfMoon * size)); int r = GetRandomValue((int)(minSizeOfMoon * size), (int)(maxSizeOfMoon * size));
int ring1 = (float)r * bigRingRatio;
int ring2 = (float)r * smallRingRatio;
DrawCircle(xpos, ypos, r + 20, ColorLerp(backGroundColor, moonColor, 0.02f)); DrawCircle(xpos, ypos, r + ring1, ColorLerp(backGroundColor, moonColor, bigRingBlend));
DrawCircle(xpos, ypos, r + 10, ColorLerp(backGroundColor, moonColor, 0.05f)); DrawCircle(xpos, ypos, r + ring2, ColorLerp(backGroundColor, moonColor, smallRingBlend));
DrawCircle(xpos, ypos, r, moonColor); DrawCircle(xpos, ypos, r, moonColor);
} }