1786005584
This commit is contained in:
@@ -36,15 +36,12 @@ impl Trekstor {
|
||||
}
|
||||
|
||||
pub fn update(&mut self, update: UpdateFn) {
|
||||
let mut last_frame_time = Instant::now();
|
||||
loop {
|
||||
self.input.handle_event();
|
||||
self.current_time = Instant::now();
|
||||
let dt = self.current_time - self.last_time;
|
||||
|
||||
println!(
|
||||
"FPS: {}",
|
||||
(self.current_time - last_frame_time).as_secs_f64()
|
||||
);
|
||||
println!("FPS: {}", dt.as_millis());
|
||||
|
||||
if !update(&mut self.screen, &self.input) {
|
||||
return;
|
||||
@@ -53,9 +50,7 @@ impl Trekstor {
|
||||
self.screen.flush();
|
||||
self.input.finish();
|
||||
|
||||
let dt = self.current_time - self.last_time;
|
||||
self.last_time = self.current_time;
|
||||
last_frame_time = Instant::now();
|
||||
if dt < self.update_timestep {
|
||||
sleep(self.update_timestep - dt);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user