From 32a66ec64f4e09032426851455479f698ae782d0 Mon Sep 17 00:00:00 2001 From: Muhammad Nauman Raza Date: Thu, 7 Dec 2023 17:44:17 +0000 Subject: [PATCH] refactor: clippy Former-commit-id: 612296154780f9fc8500cfb18e77a7677a80f43b --- src/player.rs | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/src/player.rs b/src/player.rs index 64ef2e8..d7b52a5 100644 --- a/src/player.rs +++ b/src/player.rs @@ -41,14 +41,10 @@ pub fn movement( // 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.; - } + if keys.just_pressed(KeyCode::Space) && player.stamina >= 0.3 { + player.is_dashing = true; + player.stamina -= 0.3; + movement_distance = 256.; } if keys.pressed(KeyCode::Left) { @@ -70,11 +66,10 @@ pub fn movement( // Get the player's *forward* vector let movement_direction = transform.rotation * Vec3::Y; - 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 { + if !player.is_dashing { + 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()); } // Update the player translation with the translation