Implement tap jump and clean some fluff (#83)
CI / build-and-test (push) Successful in 1m33s
CI / production-build (push) Successful in 11m45s

Reviewed-on: #83
Co-authored-by: Álex Román Núñez <eirexe@eirteam.moe>
This commit was merged in pull request #83.
This commit is contained in:
2026-10-05 15:01:31 +00:00
committed by EIREXE
parent d2d649b059
commit 5c277a00f0
5 changed files with 67 additions and 47 deletions
+13 -16
View File
@@ -1,6 +1,8 @@
use crate::fighter::state::jump::{JumpState, JumpType};
use crate::fighter::state::jump::{self};
use crate::fighter::state::land::{LandingState, LandingType};
use crate::fighter::state::{CollisionContext, FighterState, InterruptContext, air_attack, air_dodge};
use crate::fighter::state::{
CollisionContext, FighterState, InterruptContext, air_attack, air_dodge,
};
use crate::fighter::*;
use crate::input::FighterCommands;
@@ -106,22 +108,17 @@ pub fn update_standard_motion(
airborne_common.is_fast_falling,
);
apply_air_drift(ctx.velocity, ctx.fighter_attributes, ctx.input);
apply_air_motion(
ctx.velocity,
ctx.translation,
ctx.prev_translation,
);
apply_air_motion(ctx.velocity, ctx.translation, ctx.prev_translation);
}
pub fn air_interrupts_common(ctx: &mut InterruptContext, airborne_state_common: &AirborneStateCommon) -> Option<FighterState> {
if ctx.input.has_command(FighterCommands::Jump) {
Some(FighterState::Jump(JumpState {
jump_type: JumpType::DoubleJump,
airborne_state_common: AirborneStateCommon::default(),
}))
} else {
air_dodge::check_input(ctx).or_else(|| air_attack::check_interrupt(ctx, airborne_state_common))
}
pub fn air_interrupts_common(
ctx: &mut InterruptContext,
airborne_state_common: &AirborneStateCommon,
) -> Option<FighterState> {
jump::check_input_double_jump(ctx).or_else(|| {
air_dodge::check_input(ctx)
.or_else(|| air_attack::check_interrupt(ctx, airborne_state_common))
})
}
pub fn collision_interrupt(
+46 -23
View File
@@ -1,4 +1,3 @@
use bevy::prelude::*;
use crate::{
fighter::{
@@ -21,21 +20,30 @@ pub enum JumpType {
DoubleJump,
}
#[derive(Debug, Clone, Hash)]
pub enum JumpStateInitiator {
Tap,
Button,
}
#[derive(Debug, Clone, Hash)]
pub struct JumpState {
pub jump_type: JumpType,
pub airborne_state_common: AirborneStateCommon,
pub initiator: JumpStateInitiator,
}
#[derive(Debug, Clone, Hash)]
pub struct JumpSquatState {
pub duration_counter: u32,
pub initiator: JumpStateInitiator,
}
impl JumpSquatState {
pub fn create() -> Self {
pub fn create(initiator: JumpStateInitiator) -> Self {
Self {
duration_counter: 0,
initiator,
}
}
}
@@ -68,17 +76,17 @@ impl FighterStateImpl for JumpSquatState {
direction: wavedash_dir.normalize_or_zero(),
}))
} else if self.duration_counter >= state_context.fighter_attributes.jumpsquat_duration {
info!(
"Jump {}",
state_context
let tap_jump_held = matches!(self.initiator, JumpStateInitiator::Tap)
&& state_context.input.get_last_frame().movement.y
> state_context
.game_settings
.input_common
.smash_input_axis_threshold;
let jump_type = if tap_jump_held
|| state_context
.input
.get_last_frame()
.is_held(DigitalAction::Jump)
);
let jump_type = if state_context
.input
.get_last_frame()
.is_held(DigitalAction::Jump)
{
JumpType::LongJump
} else {
@@ -87,6 +95,7 @@ impl FighterStateImpl for JumpSquatState {
Some(FighterState::Jump(JumpState {
jump_type,
airborne_state_common: AirborneStateCommon::default(),
initiator: self.initiator.clone(),
}))
} else {
None
@@ -109,6 +118,7 @@ impl FighterStateImpl for JumpSquatState {
state_context.play_animation(AnimKind::JumpSquat, false);
state_context.input.enable_hold_all(10);
state_context.input.clear_command(FighterCommands::Jump);
state_context.input.clear_command(FighterCommands::TapJump);
}
fn on_exit(&mut self, state_context: &mut crate::fighter::state::ExitContext) {
@@ -208,20 +218,33 @@ impl FighterStateImpl for JumpState {
}
pub fn check_input(state_context: &InterruptContext) -> Option<FighterState> {
state_context
.input
.has_command(FighterCommands::Jump)
.then(|| FighterState::JumpSquat(JumpSquatState::create()))
if state_context.input.has_command(FighterCommands::Jump) {
Some(FighterState::JumpSquat(JumpSquatState::create(
JumpStateInitiator::Button,
)))
} else if state_context.input.has_command(FighterCommands::TapJump) {
Some(FighterState::JumpSquat(JumpSquatState::create(
JumpStateInitiator::Tap,
)))
} else {
None
}
}
pub fn check_input_double_jump(state_context: &InterruptContext) -> Option<FighterState> {
state_context
.input
.has_command(FighterCommands::Jump)
.then(|| {
FighterState::Jump(JumpState {
jump_type: JumpType::DoubleJump,
airborne_state_common: AirborneStateCommon::default(),
})
})
if state_context.input.has_command(FighterCommands::Jump) {
Some(FighterState::Jump(JumpState {
jump_type: JumpType::DoubleJump,
airborne_state_common: AirborneStateCommon::default(),
initiator: JumpStateInitiator::Button,
}))
} else if state_context.input.has_command(FighterCommands::TapJump) {
Some(FighterState::Jump(JumpState {
jump_type: JumpType::DoubleJump,
airborne_state_common: AirborneStateCommon::default(),
initiator: JumpStateInitiator::Tap,
}))
} else {
None
}
}