()
| 20 | |
| 21 | impl Invaders { |
| 22 | pub fn new() -> Self { |
| 23 | let mut army = Vec::new(); |
| 24 | for x in 0..NUM_COLS { |
| 25 | for y in 0..NUM_ROWS { |
| 26 | if (x > 1) |
| 27 | && (x < NUM_COLS - 2) |
| 28 | && (y > 0) |
| 29 | && (y < 9) |
| 30 | && (x % 2 == 0) |
| 31 | && (y % 2 == 0) |
| 32 | { |
| 33 | army.push(Invader { x, y, points: 1 }); |
| 34 | } |
| 35 | } |
| 36 | } |
| 37 | let total_count = army.len(); |
| 38 | Self { |
| 39 | army, |
| 40 | total_count, |
| 41 | move_timer: Timer::new(Duration::from_millis(2000)), |
| 42 | direction: 1, |
| 43 | } |
| 44 | } |
| 45 | pub fn update(&mut self, delta: Duration) -> bool { |
| 46 | self.move_timer.tick(delta); |
| 47 | if self.move_timer.finished() { |
nothing calls this directly
no outgoing calls
no test coverage detected