diff --git a/src/game/mod.rs b/src/game/mod.rs index 3a5a6b2..084f796 100644 --- a/src/game/mod.rs +++ b/src/game/mod.rs @@ -54,9 +54,11 @@ impl Game for TestGame { let objs = &mut self.game_objects; let components = &mut self.components; - components.iter_mut().for_each(|component| { - component.update(frame_time, &input, renderer, objs); - }); + if !self.paused { + components.iter_mut().for_each(|component| { + component.update(frame_time, &input, renderer, objs); + }); + } // User interaction if self.input.button_just_released("quit") { @@ -123,7 +125,7 @@ impl TestGame { pub fn new(toml_path: &str, log_config: LogConfig) -> TestGame { TestGame { input: InputState::new(toml_path, log_config), - player: Player::new(), + player: Player::new(3., 30.), game_objects: vec![], text_objects: vec![], log_config, diff --git a/src/game/player.rs b/src/game/player.rs index de61bda..ac16c36 100644 --- a/src/game/player.rs +++ b/src/game/player.rs @@ -112,12 +112,12 @@ pub struct Player { } impl Player { - pub fn new() -> Player { + pub fn new(movement_speed: f32, look_sensitivity: f32) -> Player { Player { camera: Camera::new(), movement_mode: Flying, - movement_speed: 3.0, - look_sensitivity: 30.0, + movement_speed, + look_sensitivity, height: 1.0, x_look: 0.0, y_look: 0.0 diff --git a/src/input.rs b/src/input.rs index a08483f..f915f7d 100644 --- a/src/input.rs +++ b/src/input.rs @@ -655,7 +655,7 @@ pub enum AxisInput { Touch(TouchAxis) } -#[derive(Debug, Eq, PartialEq, Hash, Clone)] +#[derive(Debug, Eq, PartialEq, Clone, Hash)] pub enum DigitalInput { Keyboard(KeyboardInput), Wheel(WheelInput), @@ -663,13 +663,26 @@ pub enum DigitalInput { Controller(ControllerInput), } -#[derive(Debug, Eq, PartialEq, Hash, Clone)] +#[derive(Debug, Eq, Clone)] pub struct KeyboardInput { scan_code: ScanCode, key_code: Option, modifiers: KeyboardModifierState, } +impl PartialEq for KeyboardInput { + fn eq(&self, other: &Self) -> bool { + (self.scan_code == other.scan_code || (self.key_code != None && self.key_code == other.key_code)) && self.modifiers == other.modifiers + } +} + +impl Hash for KeyboardInput { + fn hash(&self, state: &mut H) { + self.scan_code.hash(state); + self.modifiers.hash(state); + } +} + #[derive(Debug, Eq, PartialEq, Hash, Clone)] pub struct MouseInput { button: MouseButton,