Skip to content

Commit

Permalink
fix delta time
Browse files Browse the repository at this point in the history
  • Loading branch information
prixt committed Feb 17, 2020
1 parent 142226d commit 0b35483
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/sound.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,9 @@ pub fn run(sound_rx: Receiver<SoundMessage>, ui_tx: Sender<UIMessage>) {

let mut prev = Instant::now();
loop {
let current = Instant::now();
let dt = current.duration_since(prev).as_millis() as usize;
prev = current;
for message in sound_rx.try_iter() {
use SoundMessage::*;
match message {
Expand Down Expand Up @@ -141,12 +144,9 @@ pub fn run(sound_rx: Receiver<SoundMessage>, ui_tx: Sender<UIMessage>) {
}
}
}
let current = Instant::now();
if let Some(manager) = manager.as_mut() {
let dt = current.duration_since(prev).as_millis() as usize;
manager.maintain(dt);
}
prev = current;

std::thread::sleep(Duration::from_millis(50));
}
Expand Down

0 comments on commit 0b35483

Please sign in to comment.