Add class DnaManager
This commit is contained in:
parent
a96ba1f43f
commit
dd54985dc1
@ -1,6 +1,6 @@
|
|||||||
#include <array>
|
#include <array>
|
||||||
#include "canvas/Canvas.hpp"
|
#include "canvas/Canvas.hpp"
|
||||||
|
#include "values/DnaManager.hpp"
|
||||||
class App
|
class App
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -21,5 +21,6 @@ private:
|
|||||||
Rectangle likeBox;
|
Rectangle likeBox;
|
||||||
Rectangle disLikeBox;
|
Rectangle disLikeBox;
|
||||||
|
|
||||||
Dna dna = {0};
|
Dna *dnaShow = nullptr;
|
||||||
|
DnaManager manager;
|
||||||
};
|
};
|
||||||
|
11
inc/values/DnaManager.hpp
Normal file
11
inc/values/DnaManager.hpp
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
#include "values/Dna.hpp"
|
||||||
|
|
||||||
|
class DnaManager
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
DnaManager() = default;
|
||||||
|
Dna *next(bool prevLiked);
|
||||||
|
|
||||||
|
private:
|
||||||
|
Dna dna;
|
||||||
|
};
|
13
src/App.cpp
13
src/App.cpp
@ -17,9 +17,8 @@ void App::init(int screenWidth, int screenHeight)
|
|||||||
mrand::setSeed(1);
|
mrand::setSeed(1);
|
||||||
|
|
||||||
canvasTexure = LoadRenderTexture(screenWidth, screenWidth);
|
canvasTexure = LoadRenderTexture(screenWidth, screenWidth);
|
||||||
|
dnaShow = manager.next(false);
|
||||||
newDna(dna);
|
canvas.newGen(canvasTexure, dnaShow);
|
||||||
canvas.newGen(canvasTexure, &dna);
|
|
||||||
|
|
||||||
float posY = (screenHeight - screenWidth) / 2.0f;
|
float posY = (screenHeight - screenWidth) / 2.0f;
|
||||||
float recPosX = screenWidth * 0.2f;
|
float recPosX = screenWidth * 0.2f;
|
||||||
@ -36,13 +35,13 @@ void App::update()
|
|||||||
Vector2 mouse = GetMousePosition();
|
Vector2 mouse = GetMousePosition();
|
||||||
if (CheckCollisionPointRec(mouse, disLikeBox))
|
if (CheckCollisionPointRec(mouse, disLikeBox))
|
||||||
{
|
{
|
||||||
newDna(dna);
|
dnaShow = manager.next(false);
|
||||||
canvas.newGen(canvasTexure, &dna);
|
canvas.newGen(canvasTexure, dnaShow);
|
||||||
}
|
}
|
||||||
if (CheckCollisionPointRec(mouse, likeBox))
|
if (CheckCollisionPointRec(mouse, likeBox))
|
||||||
{
|
{
|
||||||
newDna(dna);
|
dnaShow = manager.next(true);
|
||||||
canvas.newGen(canvasTexure, &dna);
|
canvas.newGen(canvasTexure, dnaShow);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
7
src/values/DnaManager.cpp
Normal file
7
src/values/DnaManager.cpp
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
#include "values/DnaManager.hpp"
|
||||||
|
|
||||||
|
Dna *DnaManager::next(bool prevLiked)
|
||||||
|
{
|
||||||
|
newDna(dna);
|
||||||
|
return &dna;
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user