diff options
author | LaG1924 <12997935+LaG1924@users.noreply.github.com> | 2018-02-25 13:05:18 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-02-25 13:05:18 +0100 |
commit | 55e432becc8c5a1b8dd6543cc0a26e0213aeb88f (patch) | |
tree | f5d7dea2c6dc5a3d2feb8f4c0413f83beef61793 /src/GlobalState.cpp | |
parent | Raycast debug render (diff) | |
parent | min/max functions (diff) | |
download | AltCraft-55e432becc8c5a1b8dd6543cc0a26e0213aeb88f.tar AltCraft-55e432becc8c5a1b8dd6543cc0a26e0213aeb88f.tar.gz AltCraft-55e432becc8c5a1b8dd6543cc0a26e0213aeb88f.tar.bz2 AltCraft-55e432becc8c5a1b8dd6543cc0a26e0213aeb88f.tar.lz AltCraft-55e432becc8c5a1b8dd6543cc0a26e0213aeb88f.tar.xz AltCraft-55e432becc8c5a1b8dd6543cc0a26e0213aeb88f.tar.zst AltCraft-55e432becc8c5a1b8dd6543cc0a26e0213aeb88f.zip |
Diffstat (limited to '')
-rw-r--r-- | src/GlobalState.cpp | 88 |
1 files changed, 49 insertions, 39 deletions
diff --git a/src/GlobalState.cpp b/src/GlobalState.cpp index ce8cb05..8d75bac 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; } }); @@ -159,7 +160,16 @@ void PhysExec() { }); listener.RegisterHandler("LmbReleased",[](const Event& eventData) { - gs->StopDigging(); + gs->CancelDigging(); + }); + + listener.RegisterHandler("RmbPressed", [](const Event& eventData) { + gs->PlaceBlock(); + }); + + listener.RegisterHandler("SelectedBlockChanged", [](const Event& eventData) { + //TODO: + //gs->CancelDigging(); }); LoopExecutionTimeController timer(std::chrono::milliseconds(8)); |