2023-12-22 16:51:21 -08:00
|
|
|
use winit::event::{ElementState, VirtualKeyCode};
|
2023-12-20 19:05:12 -08:00
|
|
|
|
|
|
|
pub struct InputStatus {
|
|
|
|
pub key_left: bool,
|
|
|
|
pub key_right: bool,
|
|
|
|
pub key_thrust: bool,
|
|
|
|
}
|
|
|
|
|
|
|
|
impl InputStatus {
|
|
|
|
pub fn new() -> Self {
|
|
|
|
InputStatus {
|
|
|
|
key_left: false,
|
|
|
|
key_right: false,
|
|
|
|
key_thrust: false,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-12-22 16:51:21 -08:00
|
|
|
pub fn process(&mut self, state: &ElementState, key: &VirtualKeyCode) {
|
|
|
|
let down = state == &ElementState::Pressed;
|
|
|
|
match key {
|
|
|
|
VirtualKeyCode::Left => self.key_left = down,
|
|
|
|
VirtualKeyCode::Right => self.key_right = down,
|
|
|
|
VirtualKeyCode::Up => self.key_thrust = down,
|
2023-12-20 19:05:12 -08:00
|
|
|
_ => {}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|