Implement tap jump and clean up some shit
CI / build-and-test (pull_request) Failing after 1m6s
CI / production-build (pull_request) Failing after 2m25s

This commit is contained in:
2026-10-04 21:32:29 +02:00
parent d2d649b059
commit 268be60150
5 changed files with 67 additions and 46 deletions
+13 -16
View File
@@ -1,6 +1,8 @@
use crate::fighter::state::jump::{JumpState, JumpType};
use crate::fighter::state::jump::{self, JumpState, JumpType};
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(
+44 -20
View File
@@ -21,21 +21,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,14 +77,14 @@ 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
.input
.get_last_frame()
.is_held(DigitalAction::Jump)
);
let jump_type = if 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)
@@ -87,6 +96,7 @@ impl FighterStateImpl for JumpSquatState {
Some(FighterState::Jump(JumpState {
jump_type,
airborne_state_common: AirborneStateCommon::default(),
initiator: self.initiator.clone(),
}))
} else {
None
@@ -109,6 +119,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 +219,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 {
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
}
}
+7 -1
View File
@@ -22,6 +22,7 @@ pub enum FighterCommands {
SmashMoveDown,
SmashMoveLeft,
SmashMoveRight,
TapJump,
}
pub(crate) fn second_binding_pressed(
@@ -32,7 +33,7 @@ pub(crate) fn second_binding_pressed(
}
impl FighterCommands {
pub const COUNT: usize = 8;
pub const COUNT: usize = 9;
pub const fn index(self) -> usize {
match self {
@@ -44,6 +45,7 @@ impl FighterCommands {
Self::SmashMoveDown => 5,
Self::SmashMoveLeft => 6,
Self::SmashMoveRight => 7,
Self::TapJump => 8,
}
}
}
@@ -514,6 +516,10 @@ pub fn postprocess_input(
y_flick_detected = !x_flick_detected;
}
if y_flick_detected && input.current_frame.movement.y > 0.0 {
input.set_lifetime(FighterCommands::TapJump, tap);
}
if attack_pressed {
let attack_type = if y_flick_detected {
if input.current_frame.movement.y > 0.0 {
-2
View File
@@ -56,8 +56,6 @@ pub fn bind_fighter_material(
continue;
};
dbg!(material_name);
if !material_name.starts_with("Fighter_") {
continue;
}
+1 -5
View File
@@ -8,16 +8,12 @@ pub mod fighter_material;
pub struct ShinesparkMaterialPlugin;
pub fn startup_test(asset_server: Res<AssetServer>) {
let test: Handle<Shader> = asset_server.load("embedded://shinespark/shaders/fighter.wgsl");
dbg!(test);
}
impl Plugin for ShinesparkMaterialPlugin {
fn build(&self, app: &mut App) {
let omit_prefix = "";
embedded_asset!(app, omit_prefix, "shaders/fighter.wgsl");
app.add_systems(Startup, startup_test)
app
.add_observer(fighter_material::bind_fighter_material)
.add_plugins(MaterialPlugin::<fighter_material::FighterMaterial>::default());
}