Implement up smash, dacus and further improve input system. (#88)
Reviewed-on: #88 Co-authored-by: Álex Román Núñez <eirexe@eirteam.moe>
This commit was merged in pull request #88.
This commit is contained in:
@@ -9,6 +9,7 @@ use crate::math::vec::FGVec2;
|
||||
pub fn sample_gamepad(pad: &Gamepad, input_map: &BaseInputMap) -> FighterInputFrame {
|
||||
let mut input_frame = FighterInputFrame::default();
|
||||
let mut movement = Vec2::ZERO;
|
||||
let mut directional_attack = Vec2::ZERO;
|
||||
|
||||
for gamepad_element in &input_map.gamepad {
|
||||
match &gamepad_element.binding {
|
||||
@@ -34,12 +35,24 @@ pub fn sample_gamepad(pad: &Gamepad, input_map: &BaseInputMap) -> FighterInputFr
|
||||
movement.y += sign as f32
|
||||
}
|
||||
}
|
||||
InputMapAction::AttackXDir(sign) => {
|
||||
if pressed {
|
||||
directional_attack.x += sign as f32;
|
||||
}
|
||||
}
|
||||
InputMapAction::AttackYDir(sign) => {
|
||||
if pressed {
|
||||
directional_attack.y += sign as f32;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// gamepad does not have a separate axis for left and right, so sign here should be 1
|
||||
GamepadBinding::Axis(axis, sign) => {
|
||||
let value = pad.get(*axis).unwrap_or(0.0) * (*sign as f32);
|
||||
match gamepad_element.action {
|
||||
InputMapAction::AttackXDir(_) => directional_attack.x += value,
|
||||
InputMapAction::AttackYDir(_) => directional_attack.y += value,
|
||||
InputMapAction::MovementXDir(_) => movement.x += value,
|
||||
InputMapAction::MovementYDir(_) => movement.y += value,
|
||||
_ => {}
|
||||
@@ -49,6 +62,10 @@ pub fn sample_gamepad(pad: &Gamepad, input_map: &BaseInputMap) -> FighterInputFr
|
||||
}
|
||||
|
||||
input_frame.movement = FGVec2::new(FGi32::from_num(movement.x), FGi32::from_num(movement.y));
|
||||
input_frame.directional_attack = FGVec2::new(
|
||||
FGi32::from_num(directional_attack.x),
|
||||
FGi32::from_num(directional_attack.y),
|
||||
);
|
||||
|
||||
input_frame
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user