input fixes!
This commit is contained in:
@@ -54,9 +54,11 @@ impl Game for TestGame {
|
|||||||
let objs = &mut self.game_objects;
|
let objs = &mut self.game_objects;
|
||||||
let components = &mut self.components;
|
let components = &mut self.components;
|
||||||
|
|
||||||
components.iter_mut().for_each(|component| {
|
if !self.paused {
|
||||||
component.update(frame_time, &input, renderer, objs);
|
components.iter_mut().for_each(|component| {
|
||||||
});
|
component.update(frame_time, &input, renderer, objs);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
// User interaction
|
// User interaction
|
||||||
if self.input.button_just_released("quit") {
|
if self.input.button_just_released("quit") {
|
||||||
@@ -123,7 +125,7 @@ impl TestGame {
|
|||||||
pub fn new(toml_path: &str, log_config: LogConfig) -> TestGame {
|
pub fn new(toml_path: &str, log_config: LogConfig) -> TestGame {
|
||||||
TestGame {
|
TestGame {
|
||||||
input: InputState::new(toml_path, log_config),
|
input: InputState::new(toml_path, log_config),
|
||||||
player: Player::new(),
|
player: Player::new(3., 30.),
|
||||||
game_objects: vec![],
|
game_objects: vec![],
|
||||||
text_objects: vec![],
|
text_objects: vec![],
|
||||||
log_config,
|
log_config,
|
||||||
|
|||||||
@@ -112,12 +112,12 @@ pub struct Player {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl Player {
|
impl Player {
|
||||||
pub fn new() -> Player {
|
pub fn new(movement_speed: f32, look_sensitivity: f32) -> Player {
|
||||||
Player {
|
Player {
|
||||||
camera: Camera::new(),
|
camera: Camera::new(),
|
||||||
movement_mode: Flying,
|
movement_mode: Flying,
|
||||||
movement_speed: 3.0,
|
movement_speed,
|
||||||
look_sensitivity: 30.0,
|
look_sensitivity,
|
||||||
height: 1.0,
|
height: 1.0,
|
||||||
x_look: 0.0,
|
x_look: 0.0,
|
||||||
y_look: 0.0
|
y_look: 0.0
|
||||||
|
|||||||
17
src/input.rs
17
src/input.rs
@@ -655,7 +655,7 @@ pub enum AxisInput {
|
|||||||
Touch(TouchAxis)
|
Touch(TouchAxis)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Eq, PartialEq, Hash, Clone)]
|
#[derive(Debug, Eq, PartialEq, Clone, Hash)]
|
||||||
pub enum DigitalInput {
|
pub enum DigitalInput {
|
||||||
Keyboard(KeyboardInput),
|
Keyboard(KeyboardInput),
|
||||||
Wheel(WheelInput),
|
Wheel(WheelInput),
|
||||||
@@ -663,13 +663,26 @@ pub enum DigitalInput {
|
|||||||
Controller(ControllerInput),
|
Controller(ControllerInput),
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Eq, PartialEq, Hash, Clone)]
|
#[derive(Debug, Eq, Clone)]
|
||||||
pub struct KeyboardInput {
|
pub struct KeyboardInput {
|
||||||
scan_code: ScanCode,
|
scan_code: ScanCode,
|
||||||
key_code: Option<VirtualKeyCode>,
|
key_code: Option<VirtualKeyCode>,
|
||||||
modifiers: KeyboardModifierState,
|
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<H: std::hash::Hasher>(&self, state: &mut H) {
|
||||||
|
self.scan_code.hash(state);
|
||||||
|
self.modifiers.hash(state);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Debug, Eq, PartialEq, Hash, Clone)]
|
#[derive(Debug, Eq, PartialEq, Hash, Clone)]
|
||||||
pub struct MouseInput {
|
pub struct MouseInput {
|
||||||
button: MouseButton,
|
button: MouseButton,
|
||||||
|
|||||||
Reference in New Issue
Block a user