diff options
author | WBoerenkamps <wrj.boerenkamps@student.avans.nl> | 2024-11-03 10:49:19 +0100 |
---|---|---|
committer | WBoerenkamps <wrj.boerenkamps@student.avans.nl> | 2024-11-03 10:49:19 +0100 |
commit | ed8534e2d150428bcbc4a6df8940323ae8db2925 (patch) | |
tree | b8c2402d13a4de190539e781c037c69d779cf95a /mwe/gameloop/src | |
parent | 5e833bba513d97c39f4e0d26b45a9095c32812a6 (diff) |
fixed gameloop double window and event poc is working again
Diffstat (limited to 'mwe/gameloop/src')
-rw-r--r-- | mwe/gameloop/src/loopManager.cpp | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/mwe/gameloop/src/loopManager.cpp b/mwe/gameloop/src/loopManager.cpp index 0392853..b075bd8 100644 --- a/mwe/gameloop/src/loopManager.cpp +++ b/mwe/gameloop/src/loopManager.cpp @@ -1,6 +1,15 @@ #include "loopManager.h" #include "timer.h" -LoopManager::LoopManager() {} +LoopManager::LoopManager() { + this->window = new WindowManager(); + +} +LoopManager::~LoopManager(){ + for(GameObject* object : this->objectList){ + delete object; + } + delete this->window; +} void LoopManager::processInput() { SDL_Event event; SDL_PollEvent(&event); @@ -42,14 +51,14 @@ void LoopManager::loop() { timer.enforceFrameRate(); } - window.destroyWindow(); + window->destroyWindow(); } void LoopManager::setup() { - gameRunning = window.initWindow(); - LoopTimer::getInstance().start(); - LoopTimer::getInstance().setFPS(500); + LoopTimer::getInstance().start(); + LoopTimer::getInstance().setFPS(10); + this->gameRunning = true; for (int i = 1; i < 3; i++) { GameObject * square = new GameObject("square2", i * 60, i * 60, 20, 20, 0, 0); @@ -59,7 +68,7 @@ void LoopManager::setup() { void LoopManager::render() { fprintf(stderr, "**********render********** \n"); if (gameRunning) { - window.render(objectList); + window->render(objectList); } } |