diff --git a/src/lib.rs b/src/lib.rs index 5216eab..74f0a2c 100644 --- a/src/lib.rs +++ b/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 = (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() } diff --git a/www b/www index 7ba57de..b0799ea 160000 --- a/www +++ b/www @@ -1 +1 @@ -Subproject commit 7ba57de4672a6a84db7f155c162a267809bacd7e +Subproject commit b0799ea316d590cd432fee5f53914287e2a328d6