Skip to content

Commit c424c08

Browse files
author
Poly
committed
Huge Performance Fix In Midi Player
Player no longer checks state of notes that played more than 0.5s ago
1 parent 15e673a commit c424c08

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/game_states/playing_state/playing_state.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,8 @@ impl<'a> GameState<'a> for PlayingState<'a> {
8787
let mut active_notes: [bool; 88] = [false; 88];
8888

8989
for n in self.notes.iter() {
90-
if n.start <= time {
90+
// Will Play In future Or Was Played Max 0.5s Ago
91+
if n.start <= time && n.start + n.duration + 0.5 > time {
9192
if n.start + n.duration >= time {
9293
active_notes[(n.note - 21) as usize] = true;
9394

@@ -103,7 +104,6 @@ impl<'a> GameState<'a> for PlayingState<'a> {
103104
}
104105
}
105106
}
106-
// println!("Left:{}", self.notes.len());
107107

108108
if self.notes.is_empty() {
109109
let menu = Box::new(crate::game_states::MenuState::new(self.display));

0 commit comments

Comments
 (0)