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

Method kill_invader_at

src/invaders.rs:85–97  ·  view source on GitHub ↗
(&mut self, x: usize, y: usize)

Source from the content-addressed store, hash-verified

83 self.army.iter().any(|invader| invader.y >= NUM_ROWS - 1)
84 }
85 pub fn kill_invader_at(&mut self, x: usize, y: usize) -> u16 {
86 if let Some(idx) = self
87 .army
88 .iter()
89 .position(|invader| (invader.x == x) && (invader.y == y))
90 {
91 let points = self.army[idx].points;
92 self.army.remove(idx);
93 points
94 } else {
95 0
96 }
97 }
98}
99
100impl Default for Invaders {

Callers 1

detect_hitsMethod · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected