2024-03-03 22:31:15 +01:00

43 lines
616 B
C++

#include "raylib.h"
#include <cstdint>
#include <vector>
#include <list>
#define MAX_DEPTH 11
struct Branch
{
Color color;
uint8_t numOfBranches;
float lenghthRatio;
};
struct DrawArgs
{
Vector2 start;
float angleDeg;
float lenghth;
int dep;
};
class Tree
{
public:
Tree(int size);
~Tree();
void draw(Rectangle dest, float rotation);
void newTree();
private:
int size = 0;
RenderTexture2D target = {0};
Vector2 start = {0};
std::vector<Branch> branches;
std::list<DrawArgs> draw_calls;
void generateBranches();
void drawTree();
void drawBranch();
Vector2 drawLine();
};