diff options
author | LaG1924 <12997935+LaG1924@users.noreply.github.com> | 2017-10-15 18:41:20 +0200 |
---|---|---|
committer | LaG1924 <12997935+LaG1924@users.noreply.github.com> | 2018-01-13 03:39:32 +0100 |
commit | 60449b3f092194087b052142be31fc74ccb9577a (patch) | |
tree | 5f70e05ebd853c754550af6ec705811ece112634 /src/GlobalState.cpp | |
parent | 2017-10-14 (diff) | |
download | AltCraft-60449b3f092194087b052142be31fc74ccb9577a.tar AltCraft-60449b3f092194087b052142be31fc74ccb9577a.tar.gz AltCraft-60449b3f092194087b052142be31fc74ccb9577a.tar.bz2 AltCraft-60449b3f092194087b052142be31fc74ccb9577a.tar.lz AltCraft-60449b3f092194087b052142be31fc74ccb9577a.tar.xz AltCraft-60449b3f092194087b052142be31fc74ccb9577a.tar.zst AltCraft-60449b3f092194087b052142be31fc74ccb9577a.zip |
Diffstat (limited to '')
-rw-r--r-- | src/GlobalState.cpp | 33 |
1 files changed, 23 insertions, 10 deletions
diff --git a/src/GlobalState.cpp b/src/GlobalState.cpp index 78fba0e..23c7e51 100644 --- a/src/GlobalState.cpp +++ b/src/GlobalState.cpp @@ -16,6 +16,7 @@ bool isPhysRunning; EventListener listener; bool isMoving[5] = { 0,0,0,0,0 }; std::thread threadPhys; +State state; void PhysExec(); @@ -149,16 +150,18 @@ void PhysExec() { while (isPhysRunning) { DebugInfo::gameThreadTime = timer.GetRealDeltaS() * 1000'00.0f; - if (isMoving[GameState::FORWARD]) - gs->HandleMovement(GameState::FORWARD, timer.GetRealDeltaS()); - if (isMoving[GameState::BACKWARD]) - gs->HandleMovement(GameState::BACKWARD, timer.GetRealDeltaS()); - if (isMoving[GameState::LEFT]) - gs->HandleMovement(GameState::LEFT, timer.GetRealDeltaS()); - if (isMoving[GameState::RIGHT]) - gs->HandleMovement(GameState::RIGHT, timer.GetRealDeltaS()); - if (isMoving[GameState::JUMP]) - gs->HandleMovement(GameState::JUMP, timer.GetRealDeltaS()); + if (state == State::Playing) { + if (isMoving[GameState::FORWARD]) + gs->HandleMovement(GameState::FORWARD, timer.GetRealDeltaS()); + if (isMoving[GameState::BACKWARD]) + gs->HandleMovement(GameState::BACKWARD, timer.GetRealDeltaS()); + if (isMoving[GameState::LEFT]) + gs->HandleMovement(GameState::LEFT, timer.GetRealDeltaS()); + if (isMoving[GameState::RIGHT]) + gs->HandleMovement(GameState::RIGHT, timer.GetRealDeltaS()); + if (isMoving[GameState::JUMP]) + gs->HandleMovement(GameState::JUMP, timer.GetRealDeltaS()); + } gs->Update(timer.GetRealDeltaS()); @@ -215,4 +218,14 @@ GameState *GlobalState::GetGameState() { Render *GlobalState::GetRender() { return render.get(); +} + +State GlobalState::GetState() { + return state; +} + +void GlobalState::SetState(const State &newState) { + if (newState != state) + EventAgregator::PushEvent(EventType::StateUpdated, StateUpdatedData{}); + state = newState; }
\ No newline at end of file |