Move DNA from Canvas to App
This commit is contained in:
parent
2a215ead5f
commit
fc7d33fb3c
@ -16,11 +16,13 @@ private:
|
||||
int pos = 0;
|
||||
int screenWidth, screenHeight;
|
||||
Canvas canvas;
|
||||
std::array< RenderTexture2D, 2> canvasTexure = { 0 };
|
||||
std::array<RenderTexture2D, 2> canvasTexure = {0};
|
||||
float rotation = 0.0f;
|
||||
Rectangle destB;
|
||||
Rectangle destA;
|
||||
|
||||
Dna dna = {0};
|
||||
|
||||
Vector2 mouseStart;
|
||||
float len;
|
||||
float ofset;
|
||||
|
@ -10,11 +10,9 @@ public:
|
||||
~Canvas() = default;
|
||||
void init(int size);
|
||||
void deinit();
|
||||
void newGen(RenderTexture2D &target);
|
||||
void newGen(RenderTexture2D &target, Dna *dna);
|
||||
|
||||
private:
|
||||
BackGround backGround;
|
||||
Tree tree;
|
||||
|
||||
Dna dna = {0};
|
||||
};
|
||||
|
@ -21,8 +21,10 @@ void App::init(int screenWidth, int screenHeight)
|
||||
canvasTexure[i] = LoadRenderTexture(screenWidth, screenWidth);
|
||||
}
|
||||
|
||||
canvas.newGen(canvasTexure[0]);
|
||||
canvas.newGen(canvasTexure[1]);
|
||||
newDna(dna);
|
||||
canvas.newGen(canvasTexure[0], &dna);
|
||||
newDna(dna);
|
||||
canvas.newGen(canvasTexure[1], &dna);
|
||||
|
||||
float posY = (screenHeight - screenWidth) / 2.0f;
|
||||
destA = {0, posY, (float)screenWidth, (float)screenWidth};
|
||||
@ -52,7 +54,8 @@ void App::update()
|
||||
|
||||
if (IsMouseButtonReleased(MOUSE_BUTTON_LEFT) && validHit)
|
||||
{
|
||||
canvas.newGen(canvasTexure[1 - pos]);
|
||||
newDna(dna);
|
||||
canvas.newGen(canvasTexure[1 - pos], &dna);
|
||||
pos = 1 - pos;
|
||||
rotation = 0.0f;
|
||||
destA = destB;
|
||||
|
@ -6,15 +6,13 @@ void Canvas::init(int size)
|
||||
tree.init(size);
|
||||
}
|
||||
|
||||
void Canvas::newGen(RenderTexture2D &target)
|
||||
void Canvas::newGen(RenderTexture2D &target, Dna *dna)
|
||||
{
|
||||
BeginTextureMode(target);
|
||||
ClearBackground(WHITE);
|
||||
|
||||
newDna(dna);
|
||||
|
||||
backGround.draw(&dna);
|
||||
tree.draw(&dna);
|
||||
backGround.draw(dna);
|
||||
tree.draw(dna);
|
||||
|
||||
EndTextureMode();
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user