From cd4ce05cb37e2aa81993a415a607422c8d8ef45d Mon Sep 17 00:00:00 2001 From: leo60228 Date: Tue, 22 Sep 2020 15:44:20 -0400 Subject: [PATCH] Split out tap_left and tap_right from player input loop The game will freeze the player immediately if they release a directional button within 3 frames of pressing it. Similar to flipping, this involves global state, and will only apply to the first player entity. --- desktop_version/src/Input.cpp | 75 ++++++++++++++++++++--------------- 1 file changed, 43 insertions(+), 32 deletions(-) diff --git a/desktop_version/src/Input.cpp b/desktop_version/src/Input.cpp index 6a7065f2..2f56a833 100644 --- a/desktop_version/src/Input.cpp +++ b/desktop_version/src/Input.cpp @@ -2168,38 +2168,6 @@ void gameinput(void) } } - if (game.press_left) - { - game.tapleft++; - } - else - { - if (game.tapleft <= 4 && game.tapleft > 0) - { - if (obj.entities[ie].vx < 0.0f) - { - obj.entities[ie].vx = 0.0f; - } - } - game.tapleft = 0; - } - if (game.press_right) - { - game.tapright++; - } - else - { - if (game.tapright <= 4 && game.tapright > 0) - { - if (obj.entities[ie].vx > 0.0f) - { - obj.entities[ie].vx = 0.0f; - } - } - game.tapright = 0; - } - - if(game.press_left) { obj.entities[ie].ax = -3; @@ -2213,6 +2181,49 @@ void gameinput(void) } } + if (game.press_left) + { + game.tapleft++; + } + else + { + if (game.tapleft <= 4 && game.tapleft > 0) + { + for (size_t ie = 0; ie < obj.entities.size(); ++ie) + { + if (obj.entities[ie].rule == 0) + { + if (obj.entities[ie].vx < 0.0f) + { + obj.entities[ie].vx = 0.0f; + } + } + } + } + game.tapleft = 0; + } + if (game.press_right) + { + game.tapright++; + } + else + { + if (game.tapright <= 4 && game.tapright > 0) + { + for (size_t ie = 0; ie < obj.entities.size(); ++ie) + { + if (obj.entities[ie].rule == 0) + { + if (obj.entities[ie].vx > 0.0f) + { + obj.entities[ie].vx = 0.0f; + } + } + } + } + game.tapright = 0; + } + if (!game.press_action) { game.jumppressed = 0;