(&mut self, invaders: &mut Invaders)
| 45 | self.shots.retain(|shot| !shot.dead()); |
| 46 | } |
| 47 | pub fn detect_hits(&mut self, invaders: &mut Invaders) -> u16 { |
| 48 | let mut hit_something = 0u16; |
| 49 | for shot in self.shots.iter_mut() { |
| 50 | if !shot.exploding { |
| 51 | let hit_count = invaders.kill_invader_at(shot.x, shot.y); |
| 52 | if hit_count > 0 { |
| 53 | hit_something += hit_count; |
| 54 | shot.explode(); |
| 55 | } |
| 56 | } |
| 57 | } |
| 58 | hit_something |
| 59 | } |
| 60 | } |
| 61 | |
| 62 | impl Default for Player { |
no test coverage detected