1786004479

This commit is contained in:
2026-08-06 10:21:19 +02:00
parent 4cd7e39c96
commit 260562806d
2 changed files with 10 additions and 9 deletions

View File

@@ -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;
}

View File

@@ -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() {