Add airdodge

This commit is contained in:
2026-08-26 22:04:41 +02:00
parent d9222409ce
commit e7e744f15e
12 changed files with 137 additions and 5 deletions
+11
View File
@@ -19,6 +19,7 @@ pub enum FighterCommands {
SmashMoveLeft,
SmashMoveRight,
Jump,
Shield,
}
/// Frames of life remaining for each buffered command. Indexed by
@@ -28,6 +29,7 @@ pub struct FighterCommandLifetimes {
smash_move_left: u8,
smash_move_right: u8,
jump: u8,
shield: u8,
}
impl Index<FighterCommands> for FighterCommandLifetimes {
@@ -38,6 +40,7 @@ impl Index<FighterCommands> for FighterCommandLifetimes {
FighterCommands::SmashMoveLeft => &self.smash_move_left,
FighterCommands::SmashMoveRight => &self.smash_move_right,
FighterCommands::Jump => &self.jump,
FighterCommands::Shield => &self.shield,
}
}
}
@@ -48,6 +51,7 @@ impl IndexMut<FighterCommands> for FighterCommandLifetimes {
FighterCommands::SmashMoveLeft => &mut self.smash_move_left,
FighterCommands::SmashMoveRight => &mut self.smash_move_right,
FighterCommands::Jump => &mut self.jump,
FighterCommands::Shield => &mut self.shield,
}
}
}
@@ -133,6 +137,13 @@ pub fn postprocess_input(
);
}
if !input.prev_frame.shield && input.current_frame.shield {
input.set_lifetime(
FighterCommands::Shield,
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
View File
@@ -9,4 +9,5 @@ pub struct FighterInputFrame {
pub movement: FGVec2,
pub directional_attack: FGVec2,
pub jump: bool,
pub shield: bool,
}
+1
View File
@@ -45,6 +45,7 @@ pub fn preprocess_keyboard_input(
input_frame.movement.y += (sign) * action_strength
}
InputMapAction::Jump => input_frame.jump = action_strength != FGi32::ZERO,
InputMapAction::Shield => input_frame.shield = action_strength != FGi32::ZERO,
}
}
+1
View File
@@ -19,6 +19,7 @@ pub enum InputMapAction {
MovementXDir(i32),
MovementYDir(i32),
Jump,
Shield,
}
#[derive(Debug)]
+15
View File
@@ -39,11 +39,26 @@ impl Plugin for FighterInputPlugin {
key: KeyCode::KeyA,
action: InputMapAction::MovementXDir(-1),
},
// up
KeyboardInputMapElement {
key: KeyCode::KeyW,
action: InputMapAction::MovementYDir(1),
},
// down
KeyboardInputMapElement {
key: KeyCode::KeyS,
action: InputMapAction::MovementYDir(-1),
},
// jump
KeyboardInputMapElement {
key: KeyCode::Space,
action: InputMapAction::Jump,
},
// shield/airdodge
KeyboardInputMapElement {
key: KeyCode::ShiftLeft,
action: InputMapAction::Shield,
},
],
})
.add_systems(ReadInputs, keyboard::preprocess_keyboard_input)