Move main in to src

This commit is contained in:
Nikola Petrov
2024-03-05 14:27:58 +01:00
parent c11135c5c4
commit 4b7fb4a011
2 changed files with 2 additions and 2 deletions

57
src/main.cpp Normal file
View File

@@ -0,0 +1,57 @@
#include "raylib.h"
#include "raymath.h"
#include "Tree.hpp"
#include "Math.hpp"
int main(void)
{
char name[] = "treender";
int screenWidth = 800;
int screenHeight = 800;
#ifdef MY_ANDROID
InitWindow(0, 0, name);
screenWidth = GetScreenWidth();
screenHeight = GetScreenHeight();
#else
InitWindow(screenWidth, screenHeight, name);
#endif
SetTargetFPS(60);
{
Tree tree(800);
tree.newTree();
Vector2 center = {(float)screenWidth / 2, (float)screenHeight / 2};
float rotation = 0.0f;
Rectangle dest = CalculateRect(center, rotation, screenWidth, screenWidth);
while (!WindowShouldClose())
{
if (IsMouseButtonDown(MOUSE_BUTTON_LEFT))
{
int mouseX = GetMouseX();
center.x = mouseX;
center.y = GetMouseY();
float l = (float)mouseX / screenWidth;
rotation = Lerp(45.0f, -45.0f, l);
dest = CalculateRect(center, rotation, screenWidth, screenWidth);
}
if (IsMouseButtonReleased(MOUSE_BUTTON_LEFT))
{
tree.newTree();
rotation = 0.0f;
center.x = screenWidth / 2;
center.y = screenHeight / 2;
dest = CalculateRect(center, rotation, screenWidth, screenWidth);
}
BeginDrawing();
ClearBackground(RED);
tree.draw(dest, rotation);
EndDrawing();
}
}
CloseWindow();
return 0;
}