diff --git a/src/logic/ingame/playerlogic.rs b/src/logic/ingame/playerlogic.rs index 5a1ace8..86891ba 100644 --- a/src/logic/ingame/playerlogic.rs +++ b/src/logic/ingame/playerlogic.rs @@ -81,7 +81,7 @@ pub fn update_player_movement( } // Move the player in their direction - let speed_multiplier; + let mut speed_multiplier; if user_request_boost && game_core.player.boost_percent >= 0.0 { // Set the speed multiplier speed_multiplier = BOOST_PLAYER_SPEED as f32; @@ -128,7 +128,7 @@ pub fn update_player_movement( // Handle flippers doing a speed increase if game_core.player.inventory.flippers.is_some() { - let speed_multiplier = speed_multiplier * game_core.player.inventory.flippers.as_ref().unwrap().speed_increase; + speed_multiplier = speed_multiplier * game_core.player.inventory.flippers.as_ref().unwrap().speed_increase; } // Update the player's breath diff --git a/src/player.rs b/src/player.rs index 265686b..cb49896 100644 --- a/src/player.rs +++ b/src/player.rs @@ -83,6 +83,10 @@ impl Player { } } + pub fn is_stun_gun_active(&self) -> bool { + return self.attacking_timer != 0.0 && self.inventory.stun_gun.is_some(); + } + /// Calculate how far the player is pub fn calculate_depth_percent(&self, world: &World) -> f32 { let dist_from_player_to_end = self.position.distance_to(world.end_position); @@ -134,7 +138,7 @@ impl Player { ); // Calculate AOE ring - if self.attacking_timer != 0.0 && self.inventory.stun_gun.is_some() { + if self.is_stun_gun_active() { let aoe_ring = calculate_linear_slide( self.attacking_timer / self.inventory.stun_gun.as_ref().unwrap().duration) as f32; self.attacking_timer = (self.attacking_timer - dt).max(0.0);