diff --git a/inc/App.hpp b/inc/App.hpp index aa7445f..0162b5c 100644 --- a/inc/App.hpp +++ b/inc/App.hpp @@ -1,13 +1,13 @@ -#include +#include #include "Tree.hpp" class App { public: - App(int screenWidth, int screenHeight); + App() = default; ~App() = default; - void init(); + void init(int screenWidth, int screenHeight); void update(); void draw(); void deinit(); @@ -15,7 +15,7 @@ public: private: int pos = 0; int screenWidth, screenHeight; - std::array trees; + std::vector trees; Vector2 center; float rotation = 0.0f; Rectangle destB; diff --git a/src/App.cpp b/src/App.cpp index 2f6699d..8c04266 100644 --- a/src/App.cpp +++ b/src/App.cpp @@ -6,12 +6,13 @@ #include "raylib.h" #include "raymath.h" -App::App(int screenWidth, int screenHeight) : screenWidth(screenWidth), screenHeight(screenHeight), trees({Tree(screenWidth), Tree(screenWidth)}) +void App::init(int screenWidth, int screenHeight) { -} + this->screenWidth = screenWidth; + this->screenHeight = screenHeight; + trees.emplace_back(screenWidth); + trees.emplace_back(screenWidth); -void App::init() -{ for (auto &&tree : trees) tree.newTree(); @@ -20,7 +21,6 @@ void App::init() destA = CalculateRect(center, rotation, screenWidth, screenWidth); destB = {destA.x, destA.y, (float)screenWidth, (float)screenWidth}; } - void App::update() { if (IsMouseButtonDown(MOUSE_BUTTON_LEFT)) diff --git a/src/main.cpp b/src/main.cpp index 2e107ac..2818fcb 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -16,8 +16,8 @@ int main(void) #endif SetTargetFPS(60); - App app(screenWidth, screenHeight); - app.init(); + App app; + app.init(screenWidth, screenHeight); while (!WindowShouldClose()) { app.update();