space ship

master
histausse 3 years ago
parent 34cb5fb51c
commit 40c026f32a
Signed by: histausse
GPG Key ID: 67486F107F62E9E9

@ -124,6 +124,28 @@ impl Universe {
}
}
pub fn new_space_ship() -> Universe {
let width : u32 = 64;
let height : u32 = 64;
let mut cells : Vec<Cell> = (0..width * height)
.map(|_i| { Cell::Dead })
.collect();
let x0 = 32;
let y0 = 32;
for (x, y) in [(0, 2), (1, 0), (1, 2), (2, 1), (2, 2)].iter().cloned() {
let i = ((y0 + y) * width + x0 + x) as usize;
cells[i] = Cell::Alive;
}
Universe {
width,
height,
cells,
}
}
pub fn render(&self) -> String {
self.to_string()
}

2
www

@ -1 +1 @@
Subproject commit 7ba57de4672a6a84db7f155c162a267809bacd7e
Subproject commit b0799ea316d590cd432fee5f53914287e2a328d6
Loading…
Cancel
Save