space ship
This commit is contained in:
parent
34cb5fb51c
commit
40c026f32a
2 changed files with 23 additions and 1 deletions
22
src/lib.rs
22
src/lib.rs
|
@ -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 {
|
pub fn render(&self) -> String {
|
||||||
self.to_string()
|
self.to_string()
|
||||||
}
|
}
|
||||||
|
|
2
www
2
www
|
@ -1 +1 @@
|
||||||
Subproject commit 7ba57de4672a6a84db7f155c162a267809bacd7e
|
Subproject commit b0799ea316d590cd432fee5f53914287e2a328d6
|
Loading…
Reference in a new issue