diff --git a/inc/App.hpp b/inc/App.hpp index d4398ba..8b7cf72 100644 --- a/inc/App.hpp +++ b/inc/App.hpp @@ -18,6 +18,8 @@ private: RenderTexture2D canvasTexure = {0}; Rectangle dest; + Rectangle likeBox; + Rectangle disLikeBox; Dna dna = {0}; }; diff --git a/src/App.cpp b/src/App.cpp index 0522879..9239280 100644 --- a/src/App.cpp +++ b/src/App.cpp @@ -22,21 +22,33 @@ void App::init(int screenWidth, int screenHeight) canvas.newGen(canvasTexure, &dna); float posY = (screenHeight - screenWidth) / 2.0f; + float recPosX = screenWidth * 0.2f; dest = {0, posY, (float)screenWidth, (float)screenWidth}; + disLikeBox = {0, posY, (float)recPosX, (float)screenWidth}; + likeBox = {screenWidth - recPosX, posY, (float)recPosX, (float)screenWidth}; } void App::update() { if (IsMouseButtonPressed(MOUSE_BUTTON_LEFT)) { - newDna(dna); - canvas.newGen(canvasTexure, &dna); + Vector2 mouse = GetMousePosition(); + if (CheckCollisionPointRec(mouse, disLikeBox)) + { + newDna(dna); + canvas.newGen(canvasTexure, &dna); + } + if (CheckCollisionPointRec(mouse, likeBox)) + { + newDna(dna); + canvas.newGen(canvasTexure, &dna); + } } } void App::draw() { - ClearBackground(RED); + ClearBackground(BLUE); Rectangle source = {0, 0, (float)canvasTexure.texture.width, (float)-canvasTexure.texture.height}; Vector2 origin = {0.0f, 0.0f}; @@ -45,8 +57,6 @@ void App::draw() void App::deinit() { - UnloadRenderTexture(canvasTexure); - canvas.deinit(); } \ No newline at end of file