From 9f911204d2a8295a669b0741a5076f55a0dd9cc5 Mon Sep 17 00:00:00 2001 From: Elisey Puzko Date: Sun, 18 Feb 2018 13:25:30 +0300 Subject: Small changes to conform Google C++ styleguide --- src/GlobalState.cpp | 77 +++++++++++++++++++++++++++-------------------------- 1 file changed, 39 insertions(+), 38 deletions(-) (limited to 'src/GlobalState.cpp') 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(std::get<0>(data), std::get<1>(data), std::get<2>(data)); - } - catch (std::exception &e) { + nc = std::make_unique(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()) { - 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()) { - 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; } }); -- cgit v1.2.3 From 99354db9db9be0f921980f081ee7ed6515d2dcdc Mon Sep 17 00:00:00 2001 From: Elisey Puzko Date: Tue, 20 Feb 2018 13:09:39 +0300 Subject: New event: SelectedBlockChanged --- src/GlobalState.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'src/GlobalState.cpp') diff --git a/src/GlobalState.cpp b/src/GlobalState.cpp index 4490862..73a34cb 100644 --- a/src/GlobalState.cpp +++ b/src/GlobalState.cpp @@ -160,7 +160,12 @@ void PhysExec() { }); listener.RegisterHandler("LmbReleased",[](const Event& eventData) { - gs->StopDigging(); + gs->CancelDigging(); + }); + + listener.RegisterHandler("SelectedBlockChanged", [](const Event& eventData) { + //TODO: + //gs->CancelDigging(); }); LoopExecutionTimeController timer(std::chrono::milliseconds(8)); -- cgit v1.2.3 From 228423d91518d0b8bd1c4bf047f3d378567e00f9 Mon Sep 17 00:00:00 2001 From: Elisey Puzko Date: Thu, 22 Feb 2018 22:07:08 +0300 Subject: Bare-bones blocks placement --- src/GlobalState.cpp | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src/GlobalState.cpp') diff --git a/src/GlobalState.cpp b/src/GlobalState.cpp index 73a34cb..8d75bac 100644 --- a/src/GlobalState.cpp +++ b/src/GlobalState.cpp @@ -163,6 +163,10 @@ void PhysExec() { gs->CancelDigging(); }); + listener.RegisterHandler("RmbPressed", [](const Event& eventData) { + gs->PlaceBlock(); + }); + listener.RegisterHandler("SelectedBlockChanged", [](const Event& eventData) { //TODO: //gs->CancelDigging(); -- cgit v1.2.3