From 65f0e3367b74e4ba10ee7b319568f860d6cb036c Mon Sep 17 00:00:00 2001 From: karl Date: Tue, 7 Jan 2020 22:19:15 +0100 Subject: [PATCH] Fix unintuitive movement (random stopping) Instead of completely stopping on key release, only that specific movement is stopped --- ECS/Systems/KeyboardMovementSystem.h | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/ECS/Systems/KeyboardMovementSystem.h b/ECS/Systems/KeyboardMovementSystem.h index 729201d..9b87408 100644 --- a/ECS/Systems/KeyboardMovementSystem.h +++ b/ECS/Systems/KeyboardMovementSystem.h @@ -28,33 +28,33 @@ class KeyboardMovementSystem : public EntitySystem, public EventSubscribereach([&](Entity *ent, ComponentHandle movement) { if (event.action == GLFW_PRESS) { - movement->moving.z = -1; + movement->moving.z -= 1; } else if (event.action == GLFW_RELEASE) { - movement->moving.z = 0; + movement->moving.z += 1; } }); } else if (event.key == GLFW_KEY_S) { myWorld->each([&](Entity *ent, ComponentHandle movement) { if (event.action == GLFW_PRESS) { - movement->moving.z = 1; + movement->moving.z += 1; } else if (event.action == GLFW_RELEASE) { - movement->moving.z = 0; + movement->moving.z -= 1; } }); } else if (event.key == GLFW_KEY_A) { myWorld->each([&](Entity *ent, ComponentHandle movement) { if (event.action == GLFW_PRESS) { - movement->moving.x = -1; + movement->moving.x -= 1; } else if (event.action == GLFW_RELEASE) { - movement->moving.x = 0; + movement->moving.x += 1; } }); } else if (event.key == GLFW_KEY_D) { myWorld->each([&](Entity *ent, ComponentHandle movement) { if (event.action == GLFW_PRESS) { - movement->moving.x = 1; + movement->moving.x += 1; } else if (event.action == GLFW_RELEASE) { - movement->moving.x = 0; + movement->moving.x -= 1; } }); }