(&mut self, width: u16, height: u16, is_playing: bool)
| 100 | } |
| 101 | |
| 102 | pub fn update_notes(&mut self, width: u16, height: u16, is_playing: bool) { |
| 103 | if !is_playing { |
| 104 | return; |
| 105 | } |
| 106 | |
| 107 | let mut rng = rand::rng(); |
| 108 | |
| 109 | self.floating_notes.retain(|note| !note.is_expired()); |
| 110 | |
| 111 | // Add a note with 50% probability |
| 112 | if rng.random_bool(0.5) && self.floating_notes.len() < 6 { |
| 113 | let actual_width = width.saturating_sub(2); |
| 114 | let actual_height = height.saturating_sub(2); |
| 115 | |
| 116 | if actual_width > 0 && actual_height > 0 { |
| 117 | let x = rng.random_range(0..actual_width); |
| 118 | let y = rng.random_range(0..actual_height); |
| 119 | |
| 120 | if let Some(note) = FloatingNote::new(x, y, &self.note_images) { |
| 121 | self.floating_notes.push(note); |
| 122 | } |
| 123 | } |
| 124 | } |
| 125 | } |
| 126 | |
| 127 | pub fn get_canvas(&mut self, width: u16, height: u16) -> Vec<Vec<Span<'static>>> { |
| 128 | // Only the right border in jukebox_side, so subtract only 1 from width |
no test coverage detected