diff options
author | Elisey Puzko <puzko.e02@gmail.com> | 2018-02-18 11:25:30 +0100 |
---|---|---|
committer | Elisey Puzko <puzko.e02@gmail.com> | 2018-02-18 11:25:30 +0100 |
commit | 9f911204d2a8295a669b0741a5076f55a0dd9cc5 (patch) | |
tree | 59d39747281f4de5d643ab8843c235f557077433 /src/GlobalState.cpp | |
parent | Raycast debug render (diff) | |
download | AltCraft-9f911204d2a8295a669b0741a5076f55a0dd9cc5.tar AltCraft-9f911204d2a8295a669b0741a5076f55a0dd9cc5.tar.gz AltCraft-9f911204d2a8295a669b0741a5076f55a0dd9cc5.tar.bz2 AltCraft-9f911204d2a8295a669b0741a5076f55a0dd9cc5.tar.lz AltCraft-9f911204d2a8295a669b0741a5076f55a0dd9cc5.tar.xz AltCraft-9f911204d2a8295a669b0741a5076f55a0dd9cc5.tar.zst AltCraft-9f911204d2a8295a669b0741a5076f55a0dd9cc5.zip |
Diffstat (limited to 'src/GlobalState.cpp')
-rw-r--r-- | src/GlobalState.cpp | 77 |
1 files changed, 39 insertions, 38 deletions
diff --git a/src/GlobalState.cpp b/src/GlobalState.cpp index ce8cb05..4490862 100644 --- a/src/GlobalState.cpp +++ b/src/GlobalState.cpp @@ -42,9 +42,10 @@ void InitEvents() { isPhysRunning = true; threadPhys = std::thread(&PhysExec); try { - nc = std::make_unique<NetworkClient>(std::get<0>(data), std::get<1>(data), std::get<2>(data)); - } - catch (std::exception &e) { + nc = std::make_unique<NetworkClient>(std::get<0>(data), + std::get<1>(data), + std::get<2>(data)); + } catch (std::exception &e) { LOG(WARNING) << "Connection failed"; PUSH_EVENT("ConnectionFailed", std::string(e.what())); isPhysRunning = false; @@ -98,47 +99,47 @@ void PhysExec() { if (!gs) return; switch (eventData.get<SDL_Scancode>()) { - 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; - default: - 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; + default: + break; + } }); listener.RegisterHandler("KeyReleased", [](const Event& eventData) { if (!gs) return; switch (eventData.get<SDL_Scancode>()) { - 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; - default: - 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; + default: + break; } }); |