summaryrefslogtreecommitdiffstats
path: root/src/ThreadGame.cpp
diff options
context:
space:
mode:
authorLaG1924 <12997935+LaG1924@users.noreply.github.com>2017-08-29 17:25:30 +0200
committerLaG1924 <12997935+LaG1924@users.noreply.github.com>2018-01-13 03:39:31 +0100
commita0d5862d99186f317a0f7364e8b6cd3cfeccfdf1 (patch)
tree7bf54f8141c513650130e8d3cc6bd8ce3f71b1fe /src/ThreadGame.cpp
parent2017-08-27 (diff)
downloadAltCraft-a0d5862d99186f317a0f7364e8b6cd3cfeccfdf1.tar
AltCraft-a0d5862d99186f317a0f7364e8b6cd3cfeccfdf1.tar.gz
AltCraft-a0d5862d99186f317a0f7364e8b6cd3cfeccfdf1.tar.bz2
AltCraft-a0d5862d99186f317a0f7364e8b6cd3cfeccfdf1.tar.lz
AltCraft-a0d5862d99186f317a0f7364e8b6cd3cfeccfdf1.tar.xz
AltCraft-a0d5862d99186f317a0f7364e8b6cd3cfeccfdf1.tar.zst
AltCraft-a0d5862d99186f317a0f7364e8b6cd3cfeccfdf1.zip
Diffstat (limited to 'src/ThreadGame.cpp')
-rw-r--r--src/ThreadGame.cpp64
1 files changed, 33 insertions, 31 deletions
diff --git a/src/ThreadGame.cpp b/src/ThreadGame.cpp
index 5e1d710..f425747 100644
--- a/src/ThreadGame.cpp
+++ b/src/ThreadGame.cpp
@@ -1,5 +1,6 @@
#include "ThreadGame.hpp"
+#include "DebugInfo.hpp"
ThreadGame::ThreadGame() {
@@ -35,21 +36,21 @@ void ThreadGame::Execute() {
if (!gs)
return;
switch (std::get<KeyPressedData>(eventData).key) {
- case sf::Keyboard::W:
- isMoving[GameState::FORWARD] = true;
- break;
- case sf::Keyboard::A:
- isMoving[GameState::LEFT] = true;
- break;
- case sf::Keyboard::S:
- isMoving[GameState::BACKWARD] = true;
- break;
- case sf::Keyboard::D:
- isMoving[GameState::RIGHT] = true;
- break;
- case sf::Keyboard::Space:
- isMoving[GameState::JUMP] = true;
- break;
+ case SDL_SCANCODE_W:
+ isMoving[GameState::FORWARD] = true;
+ break;
+ case SDL_SCANCODE_A:
+ isMoving[GameState::LEFT] = true;
+ break;
+ case SDL_SCANCODE_S:
+ isMoving[GameState::BACKWARD] = true;
+ break;
+ case SDL_SCANCODE_D:
+ isMoving[GameState::RIGHT] = true;
+ break;
+ case SDL_SCANCODE_SPACE:
+ isMoving[GameState::JUMP] = true;
+ break;
}
});
@@ -57,21 +58,21 @@ void ThreadGame::Execute() {
if (!gs)
return;
switch (std::get<KeyReleasedData>(eventData).key) {
- case sf::Keyboard::W:
- isMoving[GameState::FORWARD] = false;
- break;
- case sf::Keyboard::A:
- isMoving[GameState::LEFT] = false;
- break;
- case sf::Keyboard::S:
- isMoving[GameState::BACKWARD] = false;
- break;
- case sf::Keyboard::D:
- isMoving[GameState::RIGHT] = false;
- break;
- case sf::Keyboard::Space:
- isMoving[GameState::JUMP] = false;
- break;
+ case SDL_SCANCODE_W:
+ isMoving[GameState::FORWARD] = false;
+ break;
+ case SDL_SCANCODE_A:
+ isMoving[GameState::LEFT] = false;
+ break;
+ case SDL_SCANCODE_S:
+ isMoving[GameState::BACKWARD] = false;
+ break;
+ case SDL_SCANCODE_D:
+ isMoving[GameState::RIGHT] = false;
+ break;
+ case SDL_SCANCODE_SPACE:
+ isMoving[GameState::JUMP] = false;
+ break;
}
});
@@ -85,6 +86,7 @@ void ThreadGame::Execute() {
LoopExecutionTimeController timer(std::chrono::milliseconds(int(1.0f / 60.0f * 1000.0f)));
while (isRunning) {
+ DebugInfo::gameThreadTime = timer.GetRealDeltaS() * 1000'00.0f;
if (gs != nullptr)
gs->Update(timer.GetRealDeltaS());
listener.HandleEvent();
@@ -101,7 +103,7 @@ void ThreadGame::Execute() {
if (isMoving[GameState::JUMP])
gs->HandleMovement(GameState::JUMP, timer.GetRealDeltaS());
}
- timer.Update();
+ timer.Update();
}
gs.reset();
}