Move main in to src
This commit is contained in:
57
src/main.cpp
Normal file
57
src/main.cpp
Normal 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;
|
||||
}
|
||||
Reference in New Issue
Block a user