Add DNA to tree
This commit is contained in:
@@ -10,9 +10,11 @@ public:
|
||||
~Canvas() = default;
|
||||
void init(int size);
|
||||
void deinit();
|
||||
void newGen(RenderTexture2D& target);
|
||||
|
||||
void newGen(RenderTexture2D &target);
|
||||
|
||||
private:
|
||||
BackGround backGround;
|
||||
Tree tree;
|
||||
|
||||
Dna dna = {0};
|
||||
};
|
||||
|
@@ -3,14 +3,7 @@
|
||||
#include <list>
|
||||
#include <raylib.h>
|
||||
|
||||
#define MAX_DEPTH 11
|
||||
|
||||
struct Branch
|
||||
{
|
||||
Color color;
|
||||
uint8_t numOfBranches;
|
||||
float lenghthRatio;
|
||||
};
|
||||
#include "values/Dna.hpp"
|
||||
|
||||
struct DrawArgs
|
||||
{
|
||||
@@ -27,16 +20,16 @@ public:
|
||||
Tree() = default;
|
||||
~Tree() = default;
|
||||
void init(int size);
|
||||
void newGen();
|
||||
void draw(Dna *dna);
|
||||
|
||||
private:
|
||||
Dna *m_dna;
|
||||
|
||||
int size = 0;
|
||||
Vector2 start = {0};
|
||||
std::vector<Branch> branches;
|
||||
std::list<DrawArgs> draw_calls;
|
||||
|
||||
void generateBranches();
|
||||
void drawTree();
|
||||
void drawBranch();
|
||||
Vector2 drawLine();
|
||||
};
|
@@ -1,4 +1,12 @@
|
||||
#ifndef DNA_H
|
||||
#define DNA_H
|
||||
|
||||
#include <cinttypes>
|
||||
#include <array>
|
||||
|
||||
#include <raylib.h>
|
||||
|
||||
#define MAX_DEPTH 11
|
||||
|
||||
struct uint128
|
||||
{
|
||||
@@ -15,6 +23,13 @@ struct Moon
|
||||
float size;
|
||||
};
|
||||
|
||||
struct Branch
|
||||
{
|
||||
Color color;
|
||||
uint8_t numOfBranches;
|
||||
float lenghthRatio;
|
||||
};
|
||||
|
||||
struct Dna
|
||||
{
|
||||
Moon moon;
|
||||
@@ -22,6 +37,9 @@ struct Dna
|
||||
int time;
|
||||
uint128 mountenSeed;
|
||||
uint128 starSeed;
|
||||
std::array<Branch, MAX_DEPTH> branches;
|
||||
};
|
||||
|
||||
Dna newDna();
|
||||
void newDna(Dna &dna);
|
||||
|
||||
#endif /* DNA_H */
|
||||
|
Reference in New Issue
Block a user