Add DNA to background

This commit is contained in:
2024-12-20 23:51:42 +01:00
parent 8ad328eb1e
commit ee7b674c6d
7 changed files with 107 additions and 55 deletions

View File

@@ -1,39 +1,33 @@
#include <vector>
#include "canvas/Sun.hpp"
#include "values/Dna.hpp"
#include <raylib.h>
struct Moon
{
float x;
float y;
float size;
};
class BackGround
{
public:
BackGround() = default;
~BackGround() = default;
void init(int size);
void init(int canvasSize);
void deinit();
void newGen();
void draw();
void draw(Dna *dna);
private:
void drawStars();
void drawSun();
void drawMounten(size_t mountenSegments, int min, int max, Color color);
Dna *m_dna;
uint128 mountenSeed;
uint128 starSeed;
Sun sun;
Moon m_moon;
int colorSet;
int time;
int size = 0;
int canvasSize = 0;
constexpr static size_t numOfStarts = 150;
constexpr static float moonXOffset = 0.1f;

27
inc/values/Dna.hpp Normal file
View File

@@ -0,0 +1,27 @@
#include <cinttypes>
struct uint128
{
uint32_t a;
uint32_t b;
uint32_t c;
uint32_t d;
};
struct Moon
{
float x;
float y;
float size;
};
struct Dna
{
Moon moon;
int colorSet;
int time;
uint128 mountenSeed;
uint128 starSeed;
};
Dna newDna();

View File

@@ -1,8 +1,13 @@
#include <inttypes.h>
struct uint128;
namespace mrand
{
void setSeed(unsigned long long seed);
int getValue(int min, int max);
float getFloat(uint128 *state);
float getFloat();
int getValue(int min, int max, uint128 *state);
uint32_t getInt();
}