Fix bug and update newDna

bug: if moonY was 0 time would become 4 and it colors would be wrong
This commit is contained in:
Nikola Petrov 2025-01-02 23:07:36 +01:00
parent 91f7966224
commit a96ba1f43f
3 changed files with 17 additions and 19 deletions

View File

@ -19,6 +19,8 @@ private:
void drawSun();
void drawMounten(size_t mountenSegments, int min, int max, Color color, float scale);
int getColorSet();
int getTime();
Dna *m_dna;
uint128 mountenSeed;

View File

@ -28,7 +28,7 @@ void BackGround::draw(Dna *dna)
m_dna = dna;
mountenSeed = dna->mountenSeed;
starSeed = dna->starSeed;
int time = std::floor(Remap(m_dna->moonY / 255.0f, 0, 1, 4, 0));
int time = getTime();
int colorSet = getColorSet();
BackGroundColors::setColor(colorSet, time);
@ -177,4 +177,16 @@ int BackGround::getColorSet()
if (colorSet < 192)
return 2;
return 3;
}
int BackGround::getTime()
{
uint8_t ret = m_dna->moonY;
if (ret < 64)
return 0;
if (ret < 128)
return 1;
if (ret < 192)
return 2;
return 3;
}

View File

@ -8,26 +8,10 @@
void newDna(Dna &dna)
{
dna.mountenSeed.a = mrand::getInt();
dna.mountenSeed.b = mrand::getInt();
dna.mountenSeed.c = mrand::getInt();
dna.mountenSeed.d = mrand::getInt();
dna.starSeed.a = mrand::getInt();
dna.starSeed.b = mrand::getInt();
dna.starSeed.c = mrand::getInt();
dna.starSeed.d = mrand::getInt();
dna.branchSeed.a = mrand::getInt();
dna.branchSeed.b = mrand::getInt();
dna.branchSeed.c = mrand::getInt();
dna.branchSeed.d = mrand::getInt();
uint8_t *array = (uint8_t *)&dna;
for (size_t i = offsetof(Dna, moonX); i < sizeof(Dna); i++)
for (size_t i = 0; i < sizeof(Dna); i++)
{
array[i] = mrand::getValue(0, 254);
array[i] = mrand::getValue(0, 255);
}
return;
}