43 lines
616 B
C++
43 lines
616 B
C++
#include <cstdint>
|
|
#include <vector>
|
|
#include <list>
|
|
#include "raylib.h"
|
|
|
|
#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();
|
|
}; |