diff options
author | Loek Le Blansch <loek@pipeframe.xyz> | 2024-10-24 10:56:19 +0200 |
---|---|---|
committer | Loek Le Blansch <loek@pipeframe.xyz> | 2024-10-24 10:56:19 +0200 |
commit | e7377daf2fe3b759fbbf7e57f88c412c3b1cf011 (patch) | |
tree | d4b3af9e752b0e42116b992d27654bac5c5710ad /mwe/events/src/loopManager.cpp | |
parent | 58465175e761a908752542255fe584ce3aa1d163 (diff) |
`make format`
Diffstat (limited to 'mwe/events/src/loopManager.cpp')
-rw-r--r-- | mwe/events/src/loopManager.cpp | 45 |
1 files changed, 21 insertions, 24 deletions
diff --git a/mwe/events/src/loopManager.cpp b/mwe/events/src/loopManager.cpp index 6defda0..8ecb932 100644 --- a/mwe/events/src/loopManager.cpp +++ b/mwe/events/src/loopManager.cpp @@ -12,17 +12,15 @@ void LoopManager::processInput() { triggerEvent(KeyPressedEvent(getCustomKey(event.key.keysym.sym))); break; case SDL_MOUSEBUTTONDOWN: - int x, y; - SDL_GetMouseState(&x, &y); - triggerEvent(MousePressedEvent(x, y)); - break; + int x, y; + SDL_GetMouseState(&x, &y); + triggerEvent(MousePressedEvent(x, y)); + break; } } -void LoopManager::setRunning(bool running){ - this->gameRunning = running; -} -void LoopManager::fixedUpdate() { - //fprintf(stderr, "fixed update\n"); +void LoopManager::setRunning(bool running) { this->gameRunning = running; } +void LoopManager::fixedUpdate() { + //fprintf(stderr, "fixed update\n"); } void LoopManager::loop() { LoopTimer & timer = LoopTimer::getInstance(); @@ -45,30 +43,29 @@ void LoopManager::loop() { window.destroyWindow(); } -void onKey(const KeyPressedEvent& e) -{ - int keyCode = e.getKeyCode(); +void onKey(const KeyPressedEvent & e) { + int keyCode = e.getKeyCode(); std::cout << "keycode pressed: " << keyCode << std::endl; - } -void onMouse(const MousePressedEvent& e){ - fprintf(stderr, "mouse Position X: %d Y: %d\n", e.getMousePosition().first, e.getMousePosition().second); +void onMouse(const MousePressedEvent & e) { + fprintf(stderr, "mouse Position X: %d Y: %d\n", e.getMousePosition().first, + e.getMousePosition().second); } void LoopManager::setup() { gameRunning = window.initWindow(); LoopTimer::getInstance().start(); LoopTimer::getInstance().setFPS(50); EventHandler<KeyPressedEvent> callback = onKey; - subscribe<KeyPressedEvent>(callback,false); + subscribe<KeyPressedEvent>(callback, false); EventHandler<MousePressedEvent> mouseCallback = onMouse; - subscribe<MousePressedEvent>(mouseCallback ,false); - EventHandler<KeyPressedEvent> closeWindowCallback = [this](const KeyPressedEvent& e) { - if(e.getKeyCode() == Escape){ - this->setRunning(false); - } - }; - subscribe<KeyPressedEvent>(closeWindowCallback,false); - + subscribe<MousePressedEvent>(mouseCallback, false); + EventHandler<KeyPressedEvent> closeWindowCallback + = [this](const KeyPressedEvent & e) { + if (e.getKeyCode() == Escape) { + this->setRunning(false); + } + }; + subscribe<KeyPressedEvent>(closeWindowCallback, false); } void LoopManager::render() { //fprintf(stderr, "**********render********** \n"); |