1786004709
This commit is contained in:
@@ -1,4 +1,3 @@
|
||||
use std::thread::sleep;
|
||||
use std::time::{Duration, Instant};
|
||||
|
||||
use self::input::InputState;
|
||||
@@ -37,6 +36,7 @@ impl Trekstor {
|
||||
|
||||
pub fn update(&mut self, update: UpdateFn) {
|
||||
loop {
|
||||
println!("Step");
|
||||
self.input.handle_event();
|
||||
self.last_time = self.current_time;
|
||||
self.current_time = Instant::now();
|
||||
@@ -47,17 +47,19 @@ impl Trekstor {
|
||||
}
|
||||
|
||||
while self.accumulator > self.update_timestep {
|
||||
println!("Frame");
|
||||
|
||||
if !update(&mut self.screen, &self.input) {
|
||||
return;
|
||||
}
|
||||
|
||||
self.screen.flush();
|
||||
self.input.finish();
|
||||
|
||||
self.accumulator -= self.update_timestep;
|
||||
}
|
||||
|
||||
self.screen.flush();
|
||||
self.input.finish();
|
||||
|
||||
self.accumulator += dt;
|
||||
sleep(Duration::from_millis(1));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,7 +12,6 @@ pub struct InputState {
|
||||
keys_down: HashSet<KeyCode>,
|
||||
keys_pressed_this_update: HashSet<KeyCode>,
|
||||
keys_released_this_update: HashSet<KeyCode>,
|
||||
clear_before_next_event: bool,
|
||||
}
|
||||
|
||||
impl InputState {
|
||||
@@ -32,7 +31,6 @@ impl InputState {
|
||||
keys_down: HashSet::new(),
|
||||
keys_pressed_this_update: HashSet::new(),
|
||||
keys_released_this_update: HashSet::new(),
|
||||
clear_before_next_event: true,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -46,13 +44,6 @@ impl InputState {
|
||||
return;
|
||||
};
|
||||
|
||||
// if self.clear_before_next_event {
|
||||
// self.keys_pressed_this_update.clear();
|
||||
// self.keys_released_this_update.clear();
|
||||
// self.clear_before_next_event = false;
|
||||
// println!("cleared");
|
||||
// }
|
||||
|
||||
for event in events {
|
||||
match event.destructure() {
|
||||
EventSummary::AbsoluteAxis(_, AbsoluteAxisCode::ABS_X, value) => {
|
||||
|
||||
Reference in New Issue
Block a user