MCPcopy Create free account
hub / github.com/CleanCut/invaders / detect_hits

Method detect_hits

src/player.rs:47–59  ·  view source on GitHub ↗
(&mut self, invaders: &mut Invaders)

Source from the content-addressed store, hash-verified

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
62impl Default for Player {

Callers 1

mainFunction · 0.80

Calls 2

kill_invader_atMethod · 0.80
explodeMethod · 0.80

Tested by

no test coverage detected