From 4b8818c29ea74d98a7def2fdffef99c86070b9f9 Mon Sep 17 00:00:00 2001 From: Evan Pratten Date: Sat, 2 Oct 2021 14:48:06 -0400 Subject: [PATCH] fix double-jump bug --- game/src/scenes/ingame_scene/update.rs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/game/src/scenes/ingame_scene/update.rs b/game/src/scenes/ingame_scene/update.rs index 0969a68..0c98c86 100644 --- a/game/src/scenes/ingame_scene/update.rs +++ b/game/src/scenes/ingame_scene/update.rs @@ -22,16 +22,19 @@ impl FrameUpdate for InGameScreen { self.camera.target = Vector2::new(self.player.position.x, self.camera.target.y); // Check the only possible keyboard inputs - let is_jump = raylib.is_key_pressed(KeyboardKey::KEY_SPACE); - let is_dash = raylib.is_key_pressed(KeyboardKey::KEY_LEFT_SHIFT); - let is_pause = raylib.is_key_pressed(KeyboardKey::KEY_ESCAPE); + let is_jump = raylib.is_key_pressed(KeyboardKey::KEY_SPACE) + && !(self.player.current_state == CharacterState::Jumping); + let is_dash = raylib.is_key_pressed(KeyboardKey::KEY_LEFT_SHIFT) + && !(self.player.current_state == CharacterState::Dashing); if is_jump { self.player.update_player(Some(CharacterState::Jumping)); } else if is_dash { self.player.update_player(Some(CharacterState::Dashing)); } else { - if self.player.current_state != CharacterState::Jumping && self.player.current_state != CharacterState::Dashing { + if self.player.current_state != CharacterState::Jumping + && self.player.current_state != CharacterState::Dashing + { self.player.update_player(Some(CharacterState::Running)); } else { self.player.update_player(None);