From 98407991ad79b131f22b6b494bd7a072466e7696 Mon Sep 17 00:00:00 2001 From: DRuppFv Date: Sun, 28 Apr 2024 16:07:43 -0300 Subject: [PATCH] fix --- src/core/elements/machine_gun.rs | 15 ++++++++------- src/core/elements/musket.rs | 1 + 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/src/core/elements/machine_gun.rs b/src/core/elements/machine_gun.rs index 8b8d5a1780..a797025ef7 100644 --- a/src/core/elements/machine_gun.rs +++ b/src/core/elements/machine_gun.rs @@ -191,15 +191,14 @@ fn update( machine_gun.cooldown.tick(time.delta()); machine_gun.empty_cooldown.tick(time.delta()); + let sprite = sprites.get_mut(entity).unwrap(); + // Reset machine gun animation + if let MachineGunState::Idle = machine_gun.state { + sprite.index = 0; + } + // If the item is being held if let Some(Inv { player, .. }) = player_inventories.find_item(entity) { - let sprite = sprites.get_mut(entity).unwrap(); - - // Reset machine gun animation - if let MachineGunState::Idle = machine_gun.state { - sprite.index = 0; - } - // If the item is being used let item_used = items_used.remove(entity).is_some(); if item_used { @@ -294,6 +293,8 @@ fn update( } } } + } else { + machine_gun.state = MachineGunState::Idle; } // If the item was dropped diff --git a/src/core/elements/musket.rs b/src/core/elements/musket.rs index cb3f31fad4..67e533f5f6 100644 --- a/src/core/elements/musket.rs +++ b/src/core/elements/musket.rs @@ -208,6 +208,7 @@ fn update( let mut shoot_animation_transform = *transforms.get(entity).unwrap(); let bullet_spawn_offset = *bullet_spawn_offset; shoot_animation_transform.translation.z += 1.0; + shoot_animation_transform.translation.y += bullet_spawn_offset.y; shoot_animation_transform.translation.x += if player_sprite.flip_x { -bullet_spawn_offset.x } else {