From 66bed01926fce10e5a193222670a9c11d90f6d7d Mon Sep 17 00:00:00 2001 From: Muhammad Nauman Raza Date: Thu, 7 Dec 2023 13:48:38 +0000 Subject: [PATCH] hotfix: switch to a non-broken, blink-style of dash Former-commit-id: 8b8904b5dd130fa7f1d894eae2432f230292ef11 --- src/player.rs | 39 +++++++++++++++------------------------ 1 file changed, 15 insertions(+), 24 deletions(-) diff --git a/src/player.rs b/src/player.rs index d528365..64ef2e8 100644 --- a/src/player.rs +++ b/src/player.rs @@ -38,22 +38,19 @@ pub fn movement( rotation_factor -= 1.; } - if keys.pressed(KeyCode::Space) && player.is_dashing == false { - player.is_dashing = true; - movement_factor = 5.; - if player.stamina > 0. { - player.stamina -= 0.025; - } - if player.stamina < 0. { - player.stamina = 0.; + // Initialise the movement distance variable (to bring it into scope) + let mut movement_distance: f32 = 0.; + + let mut dashing = false; + + if keys.just_pressed(KeyCode::Space) { + if player.stamina >= 0.3 { + dashing = true; + player.stamina -= 0.3; + movement_distance = 256.; } } - - - // Initialise the movement distance variable (to bring it into scope) - let movement_distance: f32; - if keys.pressed(KeyCode::Left) { transform.rotation = Quat::from_rotation_z((90_f32).to_radians()); movement_factor = 1.; @@ -73,13 +70,11 @@ pub fn movement( // Get the player's *forward* vector let movement_direction = transform.rotation * Vec3::Y; - if player.is_dashing == true { - movement_distance = movement_factor * player.movement_speed * time.delta_seconds(); - // Change the player rotation around the Z-axis only if not dashing - transform.rotate_z(rotation_factor * player.rotation_speed * time.delta_seconds()); + if dashing == false { + movement_distance = movement_factor * player.movement_speed * time.delta_seconds(); + // Change the player rotation around the Z-axis only if not dashing + transform.rotate_z(rotation_factor * player.rotation_speed * time.delta_seconds()); } else { - movement_distance = player.stamina * movement_factor * player.movement_speed * time.delta_seconds(); - player.is_dashing = false; } // Update the player translation with the translation @@ -104,10 +99,6 @@ pub fn player_regen(mut player_query: Query<&mut Player, With>, time: Re let mut player = player_query.single_mut(); println!("{}", player.stamina); if player.stamina < 1. { - if player.stamina < 0. { - player.stamina += 0.1 * time.delta_seconds(); - } else { - player.stamina += 0.1 * time.delta_seconds(); - } + player.stamina += 0.1 * time.delta_seconds(); } }