aboutsummaryrefslogtreecommitdiff
path: root/gameloop/src/loopManager.cpp
diff options
context:
space:
mode:
authorWBoerenkamps <wrj.boerenkamps@student.avans.nl>2024-09-27 14:00:57 +0200
committerWBoerenkamps <wrj.boerenkamps@student.avans.nl>2024-09-27 14:00:57 +0200
commita78f7bbfcdabad9550afe22f615b973b92cb074f (patch)
tree318e888219965634e3b81be9b74a0522af2136e0 /gameloop/src/loopManager.cpp
parent86a7bd1aee2ee96079e00e2696a624fd6b642fa0 (diff)
parentf4560e02f703f1c6f857c8e5af63fa9fc4ca6438 (diff)
fixed merge conflict
Diffstat (limited to 'gameloop/src/loopManager.cpp')
-rw-r--r--gameloop/src/loopManager.cpp92
1 files changed, 0 insertions, 92 deletions
diff --git a/gameloop/src/loopManager.cpp b/gameloop/src/loopManager.cpp
deleted file mode 100644
index dde3cef..0000000
--- a/gameloop/src/loopManager.cpp
+++ /dev/null
@@ -1,92 +0,0 @@
-#include "loopManager.h"
-#include "timer.h"
-LoopManager::LoopManager(){
-}
-void LoopManager::processInput(){
- SDL_Event event;
- SDL_PollEvent(&event);
- switch(event.type){
- case SDL_QUIT:
- gameRunning = false;
- break;
- case SDL_KEYDOWN:
- if(event.key.keysym.sym == SDLK_ESCAPE){
- gameRunning = false;
- }else if(event.key.keysym.sym == SDLK_i){
- LoopTimer::getInstance().setGameScale(LoopTimer::getInstance().getGameScale() + 0.1);
- }else if(event.key.keysym.sym == SDLK_k){
- LoopTimer::getInstance().setGameScale(LoopTimer::getInstance().getGameScale() - 0.1);
- }
-
- break;
- }
-}
-void LoopManager::fixedUpdate(){
- fprintf(stderr,"fixed update\n");
-}
-void LoopManager::loop() {
- LoopTimer& timer = LoopTimer::getInstance();
- timer.start();
-
- while (gameRunning) {
- timer.update();
-
- while (timer.getLag() >= timer.getFixedDeltaTime()) {
- processInput();
- fixedUpdate();
- timer.advanceFixedUpdate();
- }
-
- update();
- render();
-
- timer.enforceFrameRate();
- }
-
- window.destroyWindow();
-}
-
-void LoopManager::setup(){
- gameRunning = window.initWindow();
- LoopTimer::getInstance().start();
- LoopTimer::getInstance().setFPS(500);
-
- for(int i = 1; i < 3;i++){
- GameObject* square = new GameObject("square2",i*60,i*60,20,20,0,0);
- objectList.push_back(square);
- }
-}
-void LoopManager::render(){
- fprintf(stderr,"**********render********** \n");
- if(gameRunning){
- window.render(objectList);
- }
-}
-
-void LoopManager::update() {
- fprintf(stderr, "********** normal update ********** \n");
- LoopTimer& timer = LoopTimer::getInstance();
-
- float delta = timer.getDeltaTime();
- for (int i = 0; i < objectList.size(); i++) {
- GameObject* obj = objectList[i];
-
- // Move the object based on its direction
- if (obj->direction == 1) {
- obj->setX(obj->getX() + 50 * delta);
- } else {
- obj->setX(obj->getX() - 50 * delta);
- }
-
-
- if (obj->getX() > 500) {
- obj->setX(500);
- obj->direction = 0; // Switch direction to left
- } else if (obj->getX() < 50) {
- obj->setX(50); // Clamp the position to the boundary
- obj->direction = 1; // Switch direction to right
- }
- }
-}
-
-