change color based on position of sone
This commit is contained in:
parent
f58fabcea9
commit
ed9d049fa3
@ -41,8 +41,8 @@ private:
|
||||
|
||||
constexpr static size_t numOfStarts = 150;
|
||||
constexpr static float moonXOffset = 0.1f;
|
||||
constexpr static float minSizeOfMoon = 0.075f;
|
||||
constexpr static float maxSizeOfMoon = 0.1f;
|
||||
constexpr static float minSizeOfMoon = 0.1f;
|
||||
constexpr static float maxSizeOfMoon = 0.15f;
|
||||
constexpr static float maxYPosOfMoon = 0.80f;
|
||||
constexpr static float bigRingRatio = 0.5f;
|
||||
constexpr static float smallRingRatio = 0.25f;
|
||||
|
@ -7,6 +7,7 @@ public:
|
||||
~Sun() = default;
|
||||
void init();
|
||||
void deinit();
|
||||
void setColor(Color color);
|
||||
void draw(float x, float y, float size);
|
||||
private:
|
||||
const int sizeTexute = 250;
|
||||
|
@ -1,3 +1,5 @@
|
||||
#include <cmath>
|
||||
|
||||
#include "canvas/BackGround.hpp"
|
||||
#include "canvas/BackGroundColors.hpp"
|
||||
#include "Math.hpp"
|
||||
@ -91,10 +93,23 @@ void BackGround::drawStarts()
|
||||
|
||||
void BackGround::drawSun()
|
||||
{
|
||||
int r = ((m_moon.size * (maxSizeOfMoon - minSizeOfMoon)) + minSizeOfMoon) * size;
|
||||
int r = ((m_moon.y * (maxSizeOfMoon - minSizeOfMoon)) + minSizeOfMoon) * size;
|
||||
int xpos = Lerp(size * moonXOffset, size - size * moonXOffset, m_moon.x);
|
||||
int ypos = Lerp(size * moonXOffset, maxYPosOfMoon * size, m_moon.y);
|
||||
|
||||
if (colorSet == 3) {
|
||||
sun.setColor(BackGroundColors::moonColor);
|
||||
r = ((m_moon.size * (maxSizeOfMoon - minSizeOfMoon)) + minSizeOfMoon) * size;
|
||||
}
|
||||
else {
|
||||
Color color = {0};
|
||||
color.r = 255;
|
||||
color.g = std::lerp(200, 50, m_moon.y);
|
||||
color.b = std::lerp(50, 0, m_moon.y);
|
||||
color.a = 255;
|
||||
|
||||
sun.setColor(color);
|
||||
}
|
||||
sun.draw(xpos, ypos, r);
|
||||
}
|
||||
|
||||
|
@ -58,6 +58,15 @@ void Sun::deinit()
|
||||
UnloadRenderTexture(target);
|
||||
}
|
||||
|
||||
void Sun::setColor(Color color)
|
||||
{
|
||||
c[0] = color.r / 255.0f;
|
||||
c[1] = color.g / 255.0f;
|
||||
c[2] = color.b / 255.0f;
|
||||
colorLoc = GetShaderLocation(shader, "color");
|
||||
SetShaderValue(shader, colorLoc, c, SHADER_UNIFORM_VEC3);
|
||||
}
|
||||
|
||||
void Sun::draw(float x, float y, float size)
|
||||
{
|
||||
Rectangle dest = { x-size, y - size, size * 2, size * 2};
|
||||
|
Loading…
x
Reference in New Issue
Block a user