1786004479
This commit is contained in:
@@ -37,7 +37,6 @@ impl Trekstor {
|
||||
pub fn update(&mut self, update: UpdateFn) {
|
||||
loop {
|
||||
self.input.handle_event();
|
||||
self.input.next_loop();
|
||||
self.last_time = self.current_time;
|
||||
self.current_time = Instant::now();
|
||||
let mut dt = self.current_time - self.last_time;
|
||||
@@ -56,6 +55,7 @@ impl Trekstor {
|
||||
}
|
||||
|
||||
self.screen.flush();
|
||||
self.input.finish();
|
||||
|
||||
self.accumulator += dt;
|
||||
}
|
||||
|
||||
@@ -36,8 +36,9 @@ impl InputState {
|
||||
}
|
||||
}
|
||||
|
||||
pub(super) fn next_loop(&mut self) {
|
||||
self.clear_before_next_event = true;
|
||||
pub(super) fn finish(&mut self) {
|
||||
self.keys_pressed_this_update.clear();
|
||||
self.keys_released_this_update.clear();
|
||||
}
|
||||
|
||||
pub(super) fn handle_event(&mut self) {
|
||||
@@ -45,12 +46,12 @@ 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");
|
||||
}
|
||||
// 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() {
|
||||
|
||||
Reference in New Issue
Block a user