Change to init app in init()

This commit is contained in:
Nikola Petrov 2024-03-06 22:33:17 +01:00
parent 27b822d7b1
commit dcb479912f
3 changed files with 11 additions and 11 deletions

View File

@ -1,13 +1,13 @@
#include <array> #include <vector>
#include "Tree.hpp" #include "Tree.hpp"
class App class App
{ {
public: public:
App(int screenWidth, int screenHeight); App() = default;
~App() = default; ~App() = default;
void init(); void init(int screenWidth, int screenHeight);
void update(); void update();
void draw(); void draw();
void deinit(); void deinit();
@ -15,7 +15,7 @@ public:
private: private:
int pos = 0; int pos = 0;
int screenWidth, screenHeight; int screenWidth, screenHeight;
std::array<Tree, 2> trees; std::vector<Tree> trees;
Vector2 center; Vector2 center;
float rotation = 0.0f; float rotation = 0.0f;
Rectangle destB; Rectangle destB;

View File

@ -6,12 +6,13 @@
#include "raylib.h" #include "raylib.h"
#include "raymath.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) for (auto &&tree : trees)
tree.newTree(); tree.newTree();
@ -20,7 +21,6 @@ void App::init()
destA = CalculateRect(center, rotation, screenWidth, screenWidth); destA = CalculateRect(center, rotation, screenWidth, screenWidth);
destB = {destA.x, destA.y, (float)screenWidth, (float)screenWidth}; destB = {destA.x, destA.y, (float)screenWidth, (float)screenWidth};
} }
void App::update() void App::update()
{ {
if (IsMouseButtonDown(MOUSE_BUTTON_LEFT)) if (IsMouseButtonDown(MOUSE_BUTTON_LEFT))

View File

@ -16,8 +16,8 @@ int main(void)
#endif #endif
SetTargetFPS(60); SetTargetFPS(60);
App app(screenWidth, screenHeight); App app;
app.init(); app.init(screenWidth, screenHeight);
while (!WindowShouldClose()) while (!WindowShouldClose())
{ {
app.update(); app.update();