Spremenil da drevo narise cez par framov da ni lega
This commit is contained in:
parent
ba0eecf0b7
commit
e42cd89337
@ -1,6 +1,5 @@
|
||||
#define EXT_LINK
|
||||
#define EXT_INC
|
||||
#define Wextra
|
||||
#include "build.hpp"
|
||||
#include <unordered_set>
|
||||
|
||||
|
@ -11,6 +11,7 @@ public:
|
||||
void init(int size);
|
||||
void deinit();
|
||||
void newGen(RenderTexture2D &target, Dna *dna);
|
||||
bool tick(RenderTexture2D &target);
|
||||
|
||||
private:
|
||||
BackGround backGround;
|
||||
|
@ -21,6 +21,7 @@ public:
|
||||
~Tree() = default;
|
||||
void init(int size);
|
||||
void draw(Dna *dna);
|
||||
bool tick();
|
||||
|
||||
private:
|
||||
Dna *m_dna;
|
||||
|
@ -6,7 +6,7 @@
|
||||
|
||||
#include <raylib.h>
|
||||
|
||||
#define MAX_DEPTH 11
|
||||
#define MAX_DEPTH 10
|
||||
|
||||
struct uint128
|
||||
{
|
||||
|
@ -30,7 +30,8 @@ void App::init(int screenWidth, int screenHeight)
|
||||
|
||||
void App::update()
|
||||
{
|
||||
if (IsMouseButtonPressed(MOUSE_BUTTON_LEFT))
|
||||
bool isDone = canvas.tick(canvasTexure);
|
||||
if (IsMouseButtonPressed(MOUSE_BUTTON_LEFT) && isDone)
|
||||
{
|
||||
Vector2 mouse = GetMousePosition();
|
||||
if (CheckCollisionPointRec(mouse, disLikeBox))
|
||||
|
@ -19,6 +19,14 @@ void Canvas::newGen(RenderTexture2D &target, Dna *dna)
|
||||
EndTextureMode();
|
||||
}
|
||||
|
||||
bool Canvas::tick(RenderTexture2D &target)
|
||||
{
|
||||
BeginTextureMode(target);
|
||||
bool ret = tree.tick();
|
||||
EndTextureMode();
|
||||
return ret;
|
||||
}
|
||||
|
||||
void Canvas::deinit()
|
||||
{
|
||||
backGround.deinit();
|
||||
|
@ -7,6 +7,8 @@
|
||||
#include <raylib.h>
|
||||
#include <raymath.h>
|
||||
|
||||
#define ITER_PER_FRAME 5000
|
||||
|
||||
// Public
|
||||
void Tree::init(int size)
|
||||
{
|
||||
@ -21,12 +23,21 @@ void Tree::draw(Dna *dna)
|
||||
|
||||
m_dna = dna;
|
||||
draw_calls.push_back({start, 0, (float)size / 4, 1});
|
||||
}
|
||||
|
||||
bool Tree::tick()
|
||||
{
|
||||
size_t i = 0;
|
||||
while (!draw_calls.empty())
|
||||
{
|
||||
drawBranch();
|
||||
draw_calls.pop_front();
|
||||
i++;
|
||||
if (i >= ITER_PER_FRAME)
|
||||
break;
|
||||
}
|
||||
|
||||
return draw_calls.empty();
|
||||
}
|
||||
|
||||
// Private
|
||||
|
Loading…
x
Reference in New Issue
Block a user