like/dislike box

This commit is contained in:
Nikola Petrov 2024-12-25 00:27:26 +01:00
parent 937f582b47
commit 0ccb4dbdd9
2 changed files with 17 additions and 5 deletions

View File

@ -18,6 +18,8 @@ private:
RenderTexture2D canvasTexure = {0};
Rectangle dest;
Rectangle likeBox;
Rectangle disLikeBox;
Dna dna = {0};
};

View File

@ -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();
}