Compare commits
1
Commits
895a8b8756
...
fast_fall
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f22f5c5dbc |
@@ -22,7 +22,8 @@
|
|||||||
air_jump_horizontal_velocity: "0.96",
|
air_jump_horizontal_velocity: "0.96",
|
||||||
air_jump_multiplier: "1.0",
|
air_jump_multiplier: "1.0",
|
||||||
dash_initial_velocity: "1.4",
|
dash_initial_velocity: "1.4",
|
||||||
terminal_velocity: "1.6",
|
terminal_velocity: "3.0",
|
||||||
|
fast_fall_speed: "3.5",
|
||||||
gravity: "0.084",
|
gravity: "0.084",
|
||||||
weight: "100.0",
|
weight: "100.0",
|
||||||
jumpsquat_duration: 5,
|
jumpsquat_duration: 5,
|
||||||
|
|||||||
@@ -37,6 +37,7 @@ pub struct FighterAttributes {
|
|||||||
pub ground_friction: FGi32,
|
pub ground_friction: FGi32,
|
||||||
pub terminal_velocity: FGi32,
|
pub terminal_velocity: FGi32,
|
||||||
pub gravity: FGi32,
|
pub gravity: FGi32,
|
||||||
|
pub fast_fall_speed: FGi32,
|
||||||
pub weight: FGi32,
|
pub weight: FGi32,
|
||||||
pub air_friction: FGi32,
|
pub air_friction: FGi32,
|
||||||
|
|
||||||
|
|||||||
@@ -412,7 +412,7 @@ pub fn attack_debug_gather(
|
|||||||
points.reserve(hit.hitstun_frames as usize);
|
points.reserve(hit.hitstun_frames as usize);
|
||||||
|
|
||||||
for _ in 1..hit.hitstun_frames {
|
for _ in 1..hit.hitstun_frames {
|
||||||
air::integrate_gravity(&mut fighter_vel, &manifest.attributes);
|
air::integrate_gravity(&mut fighter_vel, &manifest.attributes, false);
|
||||||
|
|
||||||
let vel = knockback_vel.length();
|
let vel = knockback_vel.length();
|
||||||
let new_vel = vel
|
let new_vel = vel
|
||||||
|
|||||||
+2
-2
@@ -38,7 +38,7 @@ use crate::{
|
|||||||
AttackKind, FighterAttackPlugin, FighterAttackScriptAssets, FighterDamage,
|
AttackKind, FighterAttackPlugin, FighterAttackScriptAssets, FighterDamage,
|
||||||
FighterKnockbackVelocity, FighterPendingHitReaction, FighterSolvedHurtboxes,
|
FighterKnockbackVelocity, FighterPendingHitReaction, FighterSolvedHurtboxes,
|
||||||
FighterStaleMoveQueue,
|
FighterStaleMoveQueue,
|
||||||
}, baked_animation::{FighterBoneIndexMap, FighterBoneMatrices}, manifest::FighterManifest, state::{FighterState, fall::FallState}, visual::FighterAnimations,
|
}, baked_animation::{FighterBoneIndexMap, FighterBoneMatrices}, manifest::FighterManifest, state::{FighterState, air::AirborneStateCommon, fall::FallState}, visual::FighterAnimations,
|
||||||
}, input::FighterInput, math::{int::FGi32, vec::FGVec2}, player::Player, schedule::GameplaySet, scripting::FighterAttackScript, stage::line::StageCollision,
|
}, input::FighterInput, math::{int::FGi32, vec::FGVec2}, player::Player, schedule::GameplaySet, scripting::FighterAttackScript, stage::line::StageCollision,
|
||||||
};
|
};
|
||||||
use state::state_interrupt_system;
|
use state::state_interrupt_system;
|
||||||
@@ -299,7 +299,7 @@ pub fn spawn_fighter(
|
|||||||
visual_root,
|
visual_root,
|
||||||
animations,
|
animations,
|
||||||
attack_scripts,
|
attack_scripts,
|
||||||
FighterState::Fall(FallState),
|
FighterState::Fall(FallState::new(AirborneStateCommon::default())),
|
||||||
animation::FighterAnimationFrame::new(animation::AnimKind::Wait, true),
|
animation::FighterAnimationFrame::new(animation::AnimKind::Wait, true),
|
||||||
(
|
(
|
||||||
baked_animation::FighterBoneMatrices::default(),
|
baked_animation::FighterBoneMatrices::default(),
|
||||||
|
|||||||
@@ -2,10 +2,44 @@ use crate::fighter::state::ground::GroundedStateCommon;
|
|||||||
use crate::fighter::state::land::{LandingState, LandingType};
|
use crate::fighter::state::land::{LandingState, LandingType};
|
||||||
use crate::fighter::state::{CollisionContext, FighterState};
|
use crate::fighter::state::{CollisionContext, FighterState};
|
||||||
use crate::fighter::*;
|
use crate::fighter::*;
|
||||||
|
use crate::input::FighterCommands;
|
||||||
|
|
||||||
pub fn integrate_gravity(velocity: &mut FighterVelocity, attributes: &FighterAttributes) {
|
#[derive(Default, Debug, Clone, Copy, Hash)]
|
||||||
|
pub struct AirborneStateCommon {
|
||||||
|
pub is_fast_falling: bool,
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn process_fast_fall(
|
||||||
|
airborne_state_common: &mut AirborneStateCommon,
|
||||||
|
input: &mut FighterInput,
|
||||||
|
velocity: &mut FighterVelocity,
|
||||||
|
attributes: &FighterAttributes,
|
||||||
|
) {
|
||||||
|
if velocity.y.is_negative() {
|
||||||
|
if input.has_command(FighterCommands::SmashMoveDown) {
|
||||||
|
airborne_state_common.is_fast_falling = true;
|
||||||
|
}
|
||||||
|
input.clear_command(FighterCommands::SmashMoveDown);
|
||||||
|
}
|
||||||
|
|
||||||
|
if airborne_state_common.is_fast_falling {
|
||||||
|
velocity.y = -attributes.fast_fall_speed;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn integrate_gravity(
|
||||||
|
velocity: &mut FighterVelocity,
|
||||||
|
attributes: &FighterAttributes,
|
||||||
|
fast_fall: bool
|
||||||
|
) {
|
||||||
velocity.y -= attributes.gravity;
|
velocity.y -= attributes.gravity;
|
||||||
velocity.y = velocity.y.max(-attributes.terminal_velocity);
|
|
||||||
|
let terminal_vel = if fast_fall {
|
||||||
|
-attributes.fast_fall_speed
|
||||||
|
} else {
|
||||||
|
-attributes.terminal_velocity
|
||||||
|
};
|
||||||
|
velocity.y = velocity.y.max(terminal_vel);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn apply_air_drift(
|
pub fn apply_air_drift(
|
||||||
@@ -56,8 +90,12 @@ pub fn apply_air_motion(
|
|||||||
translation.0 += velocity.0;
|
translation.0 += velocity.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn update_standard_motion(ctx: &mut crate::fighter::state::UpdateContext) {
|
pub fn update_standard_motion(
|
||||||
integrate_gravity(ctx.velocity, ctx.fighter_attributes);
|
ctx: &mut crate::fighter::state::UpdateContext,
|
||||||
|
airborne_common: &mut AirborneStateCommon,
|
||||||
|
) {
|
||||||
|
process_fast_fall(airborne_common, ctx.input, &mut ctx.velocity, ctx.fighter_attributes);
|
||||||
|
integrate_gravity(ctx.velocity, ctx.fighter_attributes, airborne_common.is_fast_falling);
|
||||||
apply_air_drift(ctx.velocity, ctx.fighter_attributes, ctx.input);
|
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);
|
||||||
}
|
}
|
||||||
@@ -110,6 +148,7 @@ mod tests {
|
|||||||
air_drift_max: FGi32::lit("1.2"),
|
air_drift_max: FGi32::lit("1.2"),
|
||||||
ground_friction: FGi32::ZERO,
|
ground_friction: FGi32::ZERO,
|
||||||
terminal_velocity: FGi32::ZERO,
|
terminal_velocity: FGi32::ZERO,
|
||||||
|
fast_fall_speed: FGi32::ZERO,
|
||||||
gravity: FGi32::ZERO,
|
gravity: FGi32::ZERO,
|
||||||
weight: FGi32::lit("1"),
|
weight: FGi32::lit("1"),
|
||||||
air_friction: FGi32::lit("0.001"),
|
air_friction: FGi32::lit("0.001"),
|
||||||
|
|||||||
@@ -1,13 +1,9 @@
|
|||||||
use crate::{
|
use crate::{
|
||||||
fighter::{
|
fighter::{
|
||||||
animation::AnimKind,
|
animation::AnimKind, state::{
|
||||||
state::{
|
CollisionContext, EnterContext, FighterState, FighterStateImpl, InterruptContext, UpdateContext, air::{self, AirborneStateCommon}, fall::FallState, land::LandingType,
|
||||||
CollisionContext, EnterContext, FighterState, FighterStateImpl, InterruptContext,
|
|
||||||
UpdateContext, air, fall::FallState, land::LandingType,
|
|
||||||
},
|
},
|
||||||
},
|
}, input, math::vec::FGVec2,
|
||||||
input,
|
|
||||||
math::vec::FGVec2,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#[derive(Debug, Clone, Hash)]
|
#[derive(Debug, Clone, Hash)]
|
||||||
@@ -20,7 +16,7 @@ impl FighterStateImpl for AirDodgeState {
|
|||||||
|
|
||||||
fn check_interrupt(&self, state_context: &mut InterruptContext) -> Option<FighterState> {
|
fn check_interrupt(&self, state_context: &mut InterruptContext) -> Option<FighterState> {
|
||||||
if state_context.is_current_animation_finished() {
|
if state_context.is_current_animation_finished() {
|
||||||
Some(FighterState::Fall(FallState))
|
Some(FighterState::Fall(FallState::new(AirborneStateCommon::default())))
|
||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
|
|||||||
+15
-11
@@ -1,12 +1,24 @@
|
|||||||
use super::{CollisionContext, EnterContext, FighterStateImpl, InterruptContext, UpdateContext};
|
use super::{CollisionContext, EnterContext, FighterStateImpl, InterruptContext, UpdateContext};
|
||||||
use crate::fighter::animation::AnimKind;
|
use crate::fighter::animation::AnimKind;
|
||||||
|
use crate::fighter::state::air::AirborneStateCommon;
|
||||||
use crate::fighter::state::{FighterState, air, jump};
|
use crate::fighter::state::{FighterState, air, jump};
|
||||||
|
|
||||||
#[derive(Debug, Clone, Copy, Hash)]
|
#[derive(Debug, Clone, Copy, Hash, Default)]
|
||||||
pub struct FallState;
|
pub struct FallState {
|
||||||
|
airborne_state_common: AirborneStateCommon
|
||||||
|
}
|
||||||
|
|
||||||
|
impl FallState {
|
||||||
|
pub fn new(airborne_state_common: AirborneStateCommon) -> Self {
|
||||||
|
Self {
|
||||||
|
airborne_state_common
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl FighterStateImpl for FallState {
|
impl FighterStateImpl for FallState {
|
||||||
const NAME: &'static str = "Fall";
|
const NAME: &'static str = "Fall";
|
||||||
|
|
||||||
fn check_interrupt(&self, state_context: &mut InterruptContext) -> Option<FighterState> {
|
fn check_interrupt(&self, state_context: &mut InterruptContext) -> Option<FighterState> {
|
||||||
jump::check_input_double_jump(state_context)
|
jump::check_input_double_jump(state_context)
|
||||||
}
|
}
|
||||||
@@ -16,7 +28,7 @@ impl FighterStateImpl for FallState {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn update(&mut self, state_context: &mut UpdateContext) {
|
fn update(&mut self, state_context: &mut UpdateContext) {
|
||||||
air::update_standard_motion(state_context);
|
air::update_standard_motion(state_context, &mut self.airborne_state_common);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn check_collision_interrupt(
|
fn check_collision_interrupt(
|
||||||
@@ -36,11 +48,3 @@ impl FighterStateImpl for FallState {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn check_input(state_context: &InterruptContext) -> Option<FighterState> {
|
|
||||||
let input_frame = state_context.input.get_last_frame();
|
|
||||||
|
|
||||||
if input_frame.movement.x.abs() < state_context.game_settings.input_common.stick_deadzone {
|
|
||||||
return Some(FighterState::Fall(FallState));
|
|
||||||
}
|
|
||||||
None
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
//! bit-for-bit deterministic for rollback.
|
//! bit-for-bit deterministic for rollback.
|
||||||
|
|
||||||
use crate::fighter::state::{
|
use crate::fighter::state::{
|
||||||
CollisionContext, FighterState, InterruptContext, dash, fall, ground_attack, turn, wait, walk,
|
CollisionContext, FighterState, InterruptContext, air, dash, fall, ground_attack, turn, wait, walk,
|
||||||
};
|
};
|
||||||
use crate::fighter::{
|
use crate::fighter::{
|
||||||
FighterAttributes, FighterPreviousTranslation, FighterTranslation, FighterVelocity,
|
FighterAttributes, FighterPreviousTranslation, FighterTranslation, FighterVelocity,
|
||||||
@@ -233,7 +233,7 @@ pub fn collision_interrupt(
|
|||||||
) -> Option<FighterState> {
|
) -> Option<FighterState> {
|
||||||
match collide_with_stage_grounded(ctx, common, can_walk_off) {
|
match collide_with_stage_grounded(ctx, common, can_walk_off) {
|
||||||
GroundedMotionResult::InGround => None,
|
GroundedMotionResult::InGround => None,
|
||||||
GroundedMotionResult::InAir => Some(FighterState::Fall(fall::FallState)),
|
GroundedMotionResult::InAir => Some(FighterState::Fall(fall::FallState::new(air::AirborneStateCommon::default()))),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,14 +1,18 @@
|
|||||||
use crate::{
|
use crate::{
|
||||||
fighter::{
|
fighter::{
|
||||||
animation::AnimKind, attack::{self, FighterHitReaction}, state::{
|
animation::AnimKind,
|
||||||
|
attack::{self, FighterHitReaction},
|
||||||
|
state::{
|
||||||
CollisionContext, EnterContext, ExitContext, FighterState, FighterStateImpl,
|
CollisionContext, EnterContext, ExitContext, FighterState, FighterStateImpl,
|
||||||
InterruptContext, UpdateContext, air,
|
InterruptContext, UpdateContext,
|
||||||
|
air::{self, AirborneStateCommon},
|
||||||
fall::FallState,
|
fall::FallState,
|
||||||
ground::{GroundedStateCommon, collision_interrupt},
|
ground::{GroundedStateCommon, collision_interrupt},
|
||||||
land::LandingType,
|
land::LandingType,
|
||||||
wait::WaitState,
|
wait::WaitState,
|
||||||
},
|
},
|
||||||
}, math::int::FGi32,
|
},
|
||||||
|
math::int::FGi32,
|
||||||
};
|
};
|
||||||
|
|
||||||
#[derive(Clone, Debug, Hash)]
|
#[derive(Clone, Debug, Hash)]
|
||||||
@@ -21,7 +25,7 @@ pub enum HitstopStateKind {
|
|||||||
pub struct HitstunState {
|
pub struct HitstunState {
|
||||||
pub hit_reaction: FighterHitReaction,
|
pub hit_reaction: FighterHitReaction,
|
||||||
pub hitstop_kind: HitstopStateKind,
|
pub hitstop_kind: HitstopStateKind,
|
||||||
knockback_applied: bool
|
knockback_applied: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl HitstunState {
|
impl HitstunState {
|
||||||
@@ -29,7 +33,7 @@ impl HitstunState {
|
|||||||
Self {
|
Self {
|
||||||
hit_reaction,
|
hit_reaction,
|
||||||
hitstop_kind,
|
hitstop_kind,
|
||||||
knockback_applied: false
|
knockback_applied: false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -59,7 +63,9 @@ impl FighterStateImpl for HitstunState {
|
|||||||
grounded_common: grounded_state_common.clone(),
|
grounded_common: grounded_state_common.clone(),
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
HitstopStateKind::Airborne => Some(FighterState::Fall(FallState)),
|
HitstopStateKind::Airborne => {
|
||||||
|
Some(FighterState::Fall(FallState::new(AirborneStateCommon::default())))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
@@ -69,16 +75,21 @@ impl FighterStateImpl for HitstunState {
|
|||||||
fn update(&mut self, ctx: &mut UpdateContext) {
|
fn update(&mut self, ctx: &mut UpdateContext) {
|
||||||
if !self.knockback_applied {
|
if !self.knockback_applied {
|
||||||
let launch_direction = attack::directional_influence::apply_directional_influence(
|
let launch_direction = attack::directional_influence::apply_directional_influence(
|
||||||
ctx.input.get_last_frame().movement,
|
ctx.input.get_last_frame().movement,
|
||||||
self.hit_reaction.launch_angle,
|
self.hit_reaction.launch_angle,
|
||||||
ctx.game_settings.fighter_common.di_max_angle
|
ctx.game_settings.fighter_common.di_max_angle,
|
||||||
);
|
);
|
||||||
|
|
||||||
ctx.knockback_velocity.0 = launch_direction * self.hit_reaction.launch_velocity;
|
ctx.knockback_velocity.0 = launch_direction * self.hit_reaction.launch_velocity;
|
||||||
self.knockback_applied = true;
|
self.knockback_applied = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
air::integrate_gravity(ctx.velocity, ctx.fighter_attributes);
|
match self.hitstop_kind {
|
||||||
|
HitstopStateKind::Grounded(_) => {}
|
||||||
|
HitstopStateKind::Airborne => {
|
||||||
|
air::integrate_gravity(ctx.velocity, ctx.fighter_attributes, false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
let speed = ctx.knockback_velocity.length();
|
let speed = ctx.knockback_velocity.length();
|
||||||
let next_speed = speed
|
let next_speed = speed
|
||||||
@@ -113,10 +124,8 @@ impl FighterStateImpl for HitstunState {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn is_visually_grounded<'a>(
|
fn is_visually_grounded<'a>(&'a self) -> bool {
|
||||||
&'a self,
|
|
||||||
) -> bool {
|
|
||||||
match self.hitstop_kind {
|
match self.hitstop_kind {
|
||||||
HitstopStateKind::Grounded(_) => true,
|
HitstopStateKind::Grounded(_) => true,
|
||||||
HitstopStateKind::Airborne => false,
|
HitstopStateKind::Airborne => false,
|
||||||
|
|||||||
@@ -2,16 +2,10 @@ use bevy::prelude::*;
|
|||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
fighter::{
|
fighter::{
|
||||||
animation::AnimKind,
|
animation::AnimKind, state::{
|
||||||
state::{
|
CollisionContext, EnterContext, FighterState, FighterStateImpl, InterruptContext, UpdateContext, air::{self, AirborneStateCommon}, air_dodge::{self, AirDodgeState}, ground::{self, GroundedStateCommon},
|
||||||
CollisionContext, EnterContext, FighterState, FighterStateImpl, InterruptContext,
|
|
||||||
UpdateContext, air,
|
|
||||||
air_dodge::{self, AirDodgeState},
|
|
||||||
ground::{self, GroundedStateCommon},
|
|
||||||
},
|
},
|
||||||
},
|
}, input::FighterCommands, math::{int::FGi32, vec::FGVec2},
|
||||||
input::FighterCommands,
|
|
||||||
math::{int::FGi32, vec::FGVec2},
|
|
||||||
};
|
};
|
||||||
#[derive(Debug, Hash, Clone, Copy)]
|
#[derive(Debug, Hash, Clone, Copy)]
|
||||||
pub enum JumpType {
|
pub enum JumpType {
|
||||||
@@ -23,6 +17,7 @@ pub enum JumpType {
|
|||||||
#[derive(Debug, Clone, Hash)]
|
#[derive(Debug, Clone, Hash)]
|
||||||
pub struct JumpState {
|
pub struct JumpState {
|
||||||
jump_type: JumpType,
|
jump_type: JumpType,
|
||||||
|
airborne_state_common: AirborneStateCommon,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, Hash)]
|
#[derive(Debug, Clone, Hash)]
|
||||||
@@ -74,7 +69,7 @@ impl FighterStateImpl for JumpSquatState {
|
|||||||
} else {
|
} else {
|
||||||
JumpType::ShortHop
|
JumpType::ShortHop
|
||||||
};
|
};
|
||||||
Some(FighterState::Jump(JumpState { jump_type }))
|
Some(FighterState::Jump(JumpState { jump_type, airborne_state_common: AirborneStateCommon::default() }))
|
||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
@@ -110,6 +105,7 @@ impl FighterStateImpl for JumpState {
|
|||||||
if state_context.input.has_command(FighterCommands::Jump) {
|
if state_context.input.has_command(FighterCommands::Jump) {
|
||||||
Some(FighterState::Jump(JumpState {
|
Some(FighterState::Jump(JumpState {
|
||||||
jump_type: JumpType::DoubleJump,
|
jump_type: JumpType::DoubleJump,
|
||||||
|
airborne_state_common: AirborneStateCommon::default()
|
||||||
}))
|
}))
|
||||||
} else {
|
} else {
|
||||||
air_dodge::check_input(state_context)
|
air_dodge::check_input(state_context)
|
||||||
@@ -117,7 +113,7 @@ impl FighterStateImpl for JumpState {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn update(&mut self, state_context: &mut UpdateContext) {
|
fn update(&mut self, state_context: &mut UpdateContext) {
|
||||||
air::update_standard_motion(state_context);
|
air::update_standard_motion(state_context, &mut self.airborne_state_common);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn on_enter(&mut self, state_context: &mut EnterContext) {
|
fn on_enter(&mut self, state_context: &mut EnterContext) {
|
||||||
@@ -205,6 +201,7 @@ pub fn check_input_double_jump(state_context: &InterruptContext) -> Option<Fight
|
|||||||
.then(|| {
|
.then(|| {
|
||||||
FighterState::Jump(JumpState {
|
FighterState::Jump(JumpState {
|
||||||
jump_type: JumpType::DoubleJump,
|
jump_type: JumpType::DoubleJump,
|
||||||
|
airborne_state_common: AirborneStateCommon::default()
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -148,7 +148,7 @@ pub struct ExitContext<'a> {
|
|||||||
pub struct UpdateContext<'a> {
|
pub struct UpdateContext<'a> {
|
||||||
pub translation: &'a mut FighterTranslation,
|
pub translation: &'a mut FighterTranslation,
|
||||||
pub prev_translation: &'a mut FighterPreviousTranslation,
|
pub prev_translation: &'a mut FighterPreviousTranslation,
|
||||||
pub input: &'a FighterInput,
|
pub input: &'a mut FighterInput,
|
||||||
pub hitboxes: &'a mut FighterHitboxes,
|
pub hitboxes: &'a mut FighterHitboxes,
|
||||||
pub velocity: &'a mut FighterVelocity,
|
pub velocity: &'a mut FighterVelocity,
|
||||||
pub knockback_velocity: &'a mut FighterKnockbackVelocity,
|
pub knockback_velocity: &'a mut FighterKnockbackVelocity,
|
||||||
@@ -289,7 +289,7 @@ impl<'w, 's> FighterFrameQueryItem<'w, 's> {
|
|||||||
UpdateContext {
|
UpdateContext {
|
||||||
translation: &mut self.translation,
|
translation: &mut self.translation,
|
||||||
prev_translation: &mut self.prev_translation,
|
prev_translation: &mut self.prev_translation,
|
||||||
input: &self.input,
|
input: &mut self.input,
|
||||||
hitboxes: &mut self.hitboxes,
|
hitboxes: &mut self.hitboxes,
|
||||||
velocity: &mut self.velocity,
|
velocity: &mut self.velocity,
|
||||||
knockback_velocity: &mut self.knockback_velocity,
|
knockback_velocity: &mut self.knockback_velocity,
|
||||||
|
|||||||
@@ -20,6 +20,8 @@ pub enum FighterCommands {
|
|||||||
Jump,
|
Jump,
|
||||||
Shield,
|
Shield,
|
||||||
Attack,
|
Attack,
|
||||||
|
SmashMoveUp,
|
||||||
|
SmashMoveDown,
|
||||||
SmashMoveLeft,
|
SmashMoveLeft,
|
||||||
SmashMoveRight,
|
SmashMoveRight,
|
||||||
}
|
}
|
||||||
@@ -60,6 +62,8 @@ impl FighterAttackCommandType {
|
|||||||
pub struct FighterCommandLifetimes {
|
pub struct FighterCommandLifetimes {
|
||||||
smash_move_left: u8,
|
smash_move_left: u8,
|
||||||
smash_move_right: u8,
|
smash_move_right: u8,
|
||||||
|
smash_move_down: u8,
|
||||||
|
smash_move_up: u8,
|
||||||
jump: u8,
|
jump: u8,
|
||||||
shield: u8,
|
shield: u8,
|
||||||
attack: u8,
|
attack: u8,
|
||||||
@@ -72,6 +76,8 @@ impl Index<FighterCommands> for FighterCommandLifetimes {
|
|||||||
match command {
|
match command {
|
||||||
FighterCommands::SmashMoveLeft => &self.smash_move_left,
|
FighterCommands::SmashMoveLeft => &self.smash_move_left,
|
||||||
FighterCommands::SmashMoveRight => &self.smash_move_right,
|
FighterCommands::SmashMoveRight => &self.smash_move_right,
|
||||||
|
FighterCommands::SmashMoveDown => &self.smash_move_down,
|
||||||
|
FighterCommands::SmashMoveUp => &self.smash_move_up,
|
||||||
FighterCommands::Jump => &self.jump,
|
FighterCommands::Jump => &self.jump,
|
||||||
FighterCommands::Shield => &self.shield,
|
FighterCommands::Shield => &self.shield,
|
||||||
FighterCommands::Attack => &self.attack,
|
FighterCommands::Attack => &self.attack,
|
||||||
@@ -84,6 +90,8 @@ impl IndexMut<FighterCommands> for FighterCommandLifetimes {
|
|||||||
match command {
|
match command {
|
||||||
FighterCommands::SmashMoveLeft => &mut self.smash_move_left,
|
FighterCommands::SmashMoveLeft => &mut self.smash_move_left,
|
||||||
FighterCommands::SmashMoveRight => &mut self.smash_move_right,
|
FighterCommands::SmashMoveRight => &mut self.smash_move_right,
|
||||||
|
FighterCommands::SmashMoveDown => &mut self.smash_move_down,
|
||||||
|
FighterCommands::SmashMoveUp => &mut self.smash_move_up,
|
||||||
FighterCommands::Jump => &mut self.jump,
|
FighterCommands::Jump => &mut self.jump,
|
||||||
FighterCommands::Shield => &mut self.shield,
|
FighterCommands::Shield => &mut self.shield,
|
||||||
FighterCommands::Attack => &mut self.attack,
|
FighterCommands::Attack => &mut self.attack,
|
||||||
@@ -221,6 +229,19 @@ pub fn postprocess_input(
|
|||||||
let mut x_flick_detected =
|
let mut x_flick_detected =
|
||||||
x_abs >= axis_threshold && input.frames_in_x_flick_deadzone <= frame_threshold;
|
x_abs >= axis_threshold && input.frames_in_x_flick_deadzone <= frame_threshold;
|
||||||
|
|
||||||
|
if y_flick_detected {
|
||||||
|
input.clear_command(FighterCommands::SmashMoveUp);
|
||||||
|
input.clear_command(FighterCommands::SmashMoveDown);
|
||||||
|
|
||||||
|
let command_to_set = if input.current_frame.movement.y > 0.0 {
|
||||||
|
FighterCommands::SmashMoveUp
|
||||||
|
} else {
|
||||||
|
FighterCommands::SmashMoveDown
|
||||||
|
};
|
||||||
|
|
||||||
|
input.set_lifetime(command_to_set, game_settings.input_common.input_buffer_size);
|
||||||
|
}
|
||||||
|
|
||||||
// if both flicks are detected, only one wins
|
// if both flicks are detected, only one wins
|
||||||
|
|
||||||
if x_flick_detected && y_flick_detected {
|
if x_flick_detected && y_flick_detected {
|
||||||
|
|||||||
Reference in New Issue
Block a user