Port to fixed point math
This commit is contained in:
@@ -17,6 +17,7 @@ struct FighterInputBufferedActions {}
|
||||
pub enum FighterCommands {
|
||||
SmashMoveLeft,
|
||||
SmashMoveRight,
|
||||
Jump,
|
||||
}
|
||||
|
||||
/// Frames of life remaining for each buffered command. Indexed by
|
||||
@@ -25,6 +26,7 @@ pub enum FighterCommands {
|
||||
pub struct FighterCommandLifetimes {
|
||||
smash_move_left: u8,
|
||||
smash_move_right: u8,
|
||||
jump: u8,
|
||||
}
|
||||
|
||||
impl Index<FighterCommands> for FighterCommandLifetimes {
|
||||
@@ -34,6 +36,7 @@ impl Index<FighterCommands> for FighterCommandLifetimes {
|
||||
match command {
|
||||
FighterCommands::SmashMoveLeft => &self.smash_move_left,
|
||||
FighterCommands::SmashMoveRight => &self.smash_move_right,
|
||||
FighterCommands::Jump => &self.jump,
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -43,6 +46,7 @@ impl IndexMut<FighterCommands> for FighterCommandLifetimes {
|
||||
match command {
|
||||
FighterCommands::SmashMoveLeft => &mut self.smash_move_left,
|
||||
FighterCommands::SmashMoveRight => &mut self.smash_move_right,
|
||||
FighterCommands::Jump => &mut self.jump,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+4
-2
@@ -1,10 +1,12 @@
|
||||
use bevy::prelude::*;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::math::vec::FGVec2;
|
||||
|
||||
/// One frame of a player's raw input. This is the type GGRS serializes and
|
||||
/// sends over the wire, so keep it small and keep it `PartialEq`.
|
||||
#[derive(Copy, Clone, Debug, PartialEq, Default, Serialize, Deserialize)]
|
||||
pub struct FighterInputFrame {
|
||||
pub movement: Vec2,
|
||||
pub directional_attack: Vec2,
|
||||
pub movement: FGVec2,
|
||||
pub directional_attack: FGVec2,
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ use bevy::prelude::*;
|
||||
use bevy_ggrs::{LocalInputs, LocalPlayers};
|
||||
|
||||
use crate::input::{BaseInputMap, FighterInputFrame, InputActionState, InputMapAction};
|
||||
use crate::math::int::FGi32;
|
||||
use crate::netcode::GGRSCfg;
|
||||
|
||||
pub fn preprocess_keyboard_input(
|
||||
@@ -32,16 +33,16 @@ pub fn preprocess_keyboard_input(
|
||||
};
|
||||
|
||||
let action_strength = match action_state {
|
||||
InputActionState::JustPressed | InputActionState::Pressed => 1.0f32,
|
||||
InputActionState::JustReleased | InputActionState::Released => 0.0f32,
|
||||
InputActionState::JustPressed | InputActionState::Pressed => FGi32::ONE,
|
||||
InputActionState::JustReleased | InputActionState::Released => FGi32::ZERO,
|
||||
};
|
||||
|
||||
match keyboard_elment.action {
|
||||
InputMapAction::MovementXDir(sign) => {
|
||||
input_frame.movement.x += (sign as f32) * action_strength
|
||||
input_frame.movement.x += (sign) * action_strength
|
||||
}
|
||||
InputMapAction::MovementYDir(sign) => {
|
||||
input_frame.movement.y += (sign as f32) * action_strength
|
||||
input_frame.movement.y += (sign) * action_strength
|
||||
}
|
||||
InputMapAction::Jump => todo!(),
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user