aboutsummaryrefslogtreecommitdiff
path: root/gameloop/src/loopManager.cpp
diff options
context:
space:
mode:
authorLoek Le Blansch <loek@pipeframe.xyz>2024-09-21 15:31:58 +0200
committerLoek Le Blansch <loek@pipeframe.xyz>2024-09-21 15:31:58 +0200
commitca393b6b47618e48c107ad5c021d86700343648e (patch)
tree298bff793ee331566b6be1840c8d7404409b5198 /gameloop/src/loopManager.cpp
parent8bf919f750807060f3ac2c640b8a02300af1733c (diff)
move gameloop poc to mwe
Diffstat (limited to 'gameloop/src/loopManager.cpp')
-rw-r--r--gameloop/src/loopManager.cpp72
1 files changed, 0 insertions, 72 deletions
diff --git a/gameloop/src/loopManager.cpp b/gameloop/src/loopManager.cpp
deleted file mode 100644
index f7ce886..0000000
--- a/gameloop/src/loopManager.cpp
+++ /dev/null
@@ -1,72 +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;
- }
- 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(50);
-
- for(int i = 0; i < 2;i++){
- GameObject* square = new GameObject("square2",i*40,i*40,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++) {
- objectList[i]->setX(objectList[i]->getX() + 50 * delta);
- objectList[i]->setY(objectList[i]->getY() + 50 * delta);
- }
-}
-