Integrate basic attack script debug.

This commit is contained in:
2026-08-30 14:45:26 +02:00
parent af0e567332
commit 1d5a07324d
19 changed files with 353 additions and 43 deletions
+11
View File
@@ -20,6 +20,7 @@ pub enum FighterCommands {
SmashMoveRight,
Jump,
Shield,
Attack,
}
/// Frames of life remaining for each buffered command. Indexed by
@@ -30,6 +31,7 @@ pub struct FighterCommandLifetimes {
smash_move_right: u8,
jump: u8,
shield: u8,
attack: u8,
}
impl Index<FighterCommands> for FighterCommandLifetimes {
@@ -41,6 +43,7 @@ impl Index<FighterCommands> for FighterCommandLifetimes {
FighterCommands::SmashMoveRight => &self.smash_move_right,
FighterCommands::Jump => &self.jump,
FighterCommands::Shield => &self.shield,
FighterCommands::Attack => &self.attack,
}
}
}
@@ -52,6 +55,7 @@ impl IndexMut<FighterCommands> for FighterCommandLifetimes {
FighterCommands::SmashMoveRight => &mut self.smash_move_right,
FighterCommands::Jump => &mut self.jump,
FighterCommands::Shield => &mut self.shield,
FighterCommands::Attack => &mut self.attack,
}
}
}
@@ -148,6 +152,13 @@ pub fn postprocess_input(
);
}
if !input.prev_frame.attack && input.current_frame.attack {
input.set_lifetime(
FighterCommands::Attack,
game_settings.input_common.input_buffer_size,
);
}
if x_abs >= axis_threshold && input.frames_in_smash_move_deadzone <= frame_threshold {
input.clear_command(FighterCommands::SmashMoveLeft);
input.clear_command(FighterCommands::SmashMoveRight);
+1 -1
View File
@@ -1,6 +1,6 @@
use bevy_egui::prelude::*;
use crate::input::FighterInput;
use crate::{fighter::{FighterHitboxes, animation::FighterAnimationFrame, visual::FighterAnimations}, input::FighterInput};
use bevy::prelude::*;
pub fn input_debug(mut contexts: EguiContexts, query: Query<&FighterInput>) -> Result {
+1
View File
@@ -10,4 +10,5 @@ pub struct FighterInputFrame {
pub directional_attack: FGVec2,
pub jump: bool,
pub shield: bool,
pub attack: bool,
}
+1
View File
@@ -17,6 +17,7 @@ pub fn sample_gamepad(pad: &Gamepad, input_map: &BaseInputMap) -> FighterInputFr
match gamepad_element.action {
InputMapAction::Jump => input_frame.jump |= pressed,
InputMapAction::Shield => input_frame.shield |= pressed,
InputMapAction::Attack => input_frame.attack |= pressed,
// Digital buttons driving movement isn't used by the
// default bindings (the stick covers that), but stay
// consistent with the keyboard backend if one is added.
+1
View File
@@ -32,6 +32,7 @@ pub fn sample_keyboard(key: &ButtonInput<KeyCode>, input_map: &BaseInputMap) ->
}
InputMapAction::Jump => input_frame.jump = action_strength != FGi32::ZERO,
InputMapAction::Shield => input_frame.shield = action_strength != FGi32::ZERO,
InputMapAction::Attack => input_frame.attack = action_strength != FGi32::ZERO,
}
}
+1
View File
@@ -16,6 +16,7 @@ pub enum InputMapAction {
MovementYDir(i32),
Jump,
Shield,
Attack,
}
#[derive(Debug)]
+10
View File
@@ -67,6 +67,11 @@ impl Plugin for FighterInputPlugin {
key: KeyCode::ShiftLeft,
action: InputMapAction::Shield,
},
// attack
KeyboardInputMapElement {
key: KeyCode::KeyJ,
action: InputMapAction::Attack,
},
],
gamepad: vec![
// left stick
@@ -92,6 +97,11 @@ impl Plugin for FighterInputPlugin {
binding: GamepadBinding::Button(GamepadButton::RightTrigger),
action: InputMapAction::Shield,
},
// attack
GamepadInputMapElement {
binding: GamepadBinding::Button(GamepadButton::East),
action: InputMapAction::Attack,
},
],
})
.add_plugins(gamecube::GamecubeAdapterPlugin)