like/dislike box
This commit is contained in:
parent
937f582b47
commit
0ccb4dbdd9
@ -18,6 +18,8 @@ private:
|
|||||||
RenderTexture2D canvasTexure = {0};
|
RenderTexture2D canvasTexure = {0};
|
||||||
|
|
||||||
Rectangle dest;
|
Rectangle dest;
|
||||||
|
Rectangle likeBox;
|
||||||
|
Rectangle disLikeBox;
|
||||||
|
|
||||||
Dna dna = {0};
|
Dna dna = {0};
|
||||||
};
|
};
|
||||||
|
20
src/App.cpp
20
src/App.cpp
@ -22,21 +22,33 @@ void App::init(int screenWidth, int screenHeight)
|
|||||||
canvas.newGen(canvasTexure, &dna);
|
canvas.newGen(canvasTexure, &dna);
|
||||||
|
|
||||||
float posY = (screenHeight - screenWidth) / 2.0f;
|
float posY = (screenHeight - screenWidth) / 2.0f;
|
||||||
|
float recPosX = screenWidth * 0.2f;
|
||||||
dest = {0, posY, (float)screenWidth, (float)screenWidth};
|
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()
|
void App::update()
|
||||||
{
|
{
|
||||||
if (IsMouseButtonPressed(MOUSE_BUTTON_LEFT))
|
if (IsMouseButtonPressed(MOUSE_BUTTON_LEFT))
|
||||||
{
|
{
|
||||||
newDna(dna);
|
Vector2 mouse = GetMousePosition();
|
||||||
canvas.newGen(canvasTexure, &dna);
|
if (CheckCollisionPointRec(mouse, disLikeBox))
|
||||||
|
{
|
||||||
|
newDna(dna);
|
||||||
|
canvas.newGen(canvasTexure, &dna);
|
||||||
|
}
|
||||||
|
if (CheckCollisionPointRec(mouse, likeBox))
|
||||||
|
{
|
||||||
|
newDna(dna);
|
||||||
|
canvas.newGen(canvasTexure, &dna);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void App::draw()
|
void App::draw()
|
||||||
{
|
{
|
||||||
ClearBackground(RED);
|
ClearBackground(BLUE);
|
||||||
|
|
||||||
Rectangle source = {0, 0, (float)canvasTexure.texture.width, (float)-canvasTexure.texture.height};
|
Rectangle source = {0, 0, (float)canvasTexure.texture.width, (float)-canvasTexure.texture.height};
|
||||||
Vector2 origin = {0.0f, 0.0f};
|
Vector2 origin = {0.0f, 0.0f};
|
||||||
@ -45,8 +57,6 @@ void App::draw()
|
|||||||
|
|
||||||
void App::deinit()
|
void App::deinit()
|
||||||
{
|
{
|
||||||
|
|
||||||
UnloadRenderTexture(canvasTexure);
|
UnloadRenderTexture(canvasTexure);
|
||||||
|
|
||||||
canvas.deinit();
|
canvas.deinit();
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user