Add multiple tree
eden je spredaj ki se premika ko ga zavrnemo se zamenjata in sedaj vidimo spodnjega
This commit is contained in:
parent
4b7fb4a011
commit
cf006e05e0
23
src/main.cpp
23
src/main.cpp
@ -1,8 +1,11 @@
|
||||
#include <array>
|
||||
#include "raylib.h"
|
||||
#include "raymath.h"
|
||||
#include "Tree.hpp"
|
||||
#include "Math.hpp"
|
||||
|
||||
#define MAX_TREES 2
|
||||
|
||||
int main(void)
|
||||
{
|
||||
char name[] = "treender";
|
||||
@ -18,12 +21,16 @@ int main(void)
|
||||
#endif
|
||||
SetTargetFPS(60);
|
||||
{
|
||||
Tree tree(800);
|
||||
tree.newTree();
|
||||
std::array<Tree, MAX_TREES> trees = {Tree(screenWidth), Tree(screenWidth)};
|
||||
|
||||
for (auto &&tree : trees)
|
||||
tree.newTree();
|
||||
int pos = 0;
|
||||
|
||||
Vector2 center = {(float)screenWidth / 2, (float)screenHeight / 2};
|
||||
float rotation = 0.0f;
|
||||
Rectangle dest = CalculateRect(center, rotation, screenWidth, screenWidth);
|
||||
Rectangle destA = CalculateRect(center, rotation, screenWidth, screenWidth);
|
||||
Rectangle destB = {destA.x, destA.y, (float)screenWidth, (float)screenWidth};
|
||||
|
||||
while (!WindowShouldClose())
|
||||
{
|
||||
@ -34,20 +41,22 @@ int main(void)
|
||||
center.y = GetMouseY();
|
||||
float l = (float)mouseX / screenWidth;
|
||||
rotation = Lerp(45.0f, -45.0f, l);
|
||||
dest = CalculateRect(center, rotation, screenWidth, screenWidth);
|
||||
destA = CalculateRect(center, rotation, screenWidth, screenWidth);
|
||||
}
|
||||
|
||||
if (IsMouseButtonReleased(MOUSE_BUTTON_LEFT))
|
||||
{
|
||||
tree.newTree();
|
||||
trees[1 - pos].newTree();
|
||||
pos = 1 - pos;
|
||||
rotation = 0.0f;
|
||||
center.x = screenWidth / 2;
|
||||
center.y = screenHeight / 2;
|
||||
dest = CalculateRect(center, rotation, screenWidth, screenWidth);
|
||||
destA = CalculateRect(center, rotation, screenWidth, screenWidth);
|
||||
}
|
||||
BeginDrawing();
|
||||
ClearBackground(RED);
|
||||
tree.draw(dest, rotation);
|
||||
trees[pos].draw(destB, 0.0f);
|
||||
trees[1 - pos].draw(destA, rotation);
|
||||
EndDrawing();
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user