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

Method new

src/invaders.rs:22–44  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

20
21impl 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() {

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected