|
@@ -34,19 +34,20 @@ impl World {
|
|
|
|
|
|
|
|
|
|
|
|
|
for (pos, cell) in &self.cells {
|
|
for (pos, cell) in &self.cells {
|
|
|
- dbg!(&pos);
|
|
|
|
|
|
|
+ // dbg!(&pos);
|
|
|
let min = Vector2::new(0, 0);
|
|
let min = Vector2::new(0, 0);
|
|
|
let max = self.dimensions - Vector2::new(1, 1);
|
|
let max = self.dimensions - Vector2::new(1, 1);
|
|
|
|
|
|
|
|
- let up = clamp(Vector2::new(pos.x, pos.x + 1), min, max);
|
|
|
|
|
- let down = clamp(Vector2::new(pos.x, pos.x - 1), min, max);
|
|
|
|
|
|
|
+ let up = clamp(Vector2::new(pos.x, pos.y + 1), min, max);
|
|
|
|
|
+ let down = clamp(Vector2::new(pos.x, pos.y - 1), min, max);
|
|
|
|
|
|
|
|
|
|
+ // dbg!(&up);
|
|
|
newcells.insert(up, Cell{birth: 111, maxage: 110});
|
|
newcells.insert(up, Cell{birth: 111, maxage: 110});
|
|
|
// newcells.insert(down, Cell{birth: 111, maxage: 110});
|
|
// newcells.insert(down, Cell{birth: 111, maxage: 110});
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- dbg!(self.cells.len());
|
|
|
|
|
|
|
+ // dbg!(self.cells.len());
|
|
|
World {
|
|
World {
|
|
|
cells: newcells,
|
|
cells: newcells,
|
|
|
dimensions: self.dimensions
|
|
dimensions: self.dimensions
|
|
@@ -70,15 +71,15 @@ fn main() {
|
|
|
let mut world = World::init(Vector2::new(width, height));
|
|
let mut world = World::init(Vector2::new(width, height));
|
|
|
|
|
|
|
|
world.cells.insert(Vector2::new(100, 100), Cell{birth: 0, maxage: 110});
|
|
world.cells.insert(Vector2::new(100, 100), Cell{birth: 0, maxage: 110});
|
|
|
- // world.cells.insert(Vector2::new(200, 120), Cell{birth: 1, maxage: 110});
|
|
|
|
|
|
|
+ world.cells.insert(Vector2::new(200, 120), Cell{birth: 1, maxage: 110});
|
|
|
|
|
|
|
|
// dbg!(&world);
|
|
// dbg!(&world);
|
|
|
|
|
|
|
|
- world = world.grow();
|
|
|
|
|
- world = world.grow();
|
|
|
|
|
- // dbg!(&world);
|
|
|
|
|
- world = world.grow();
|
|
|
|
|
- // dbg!(&world);
|
|
|
|
|
|
|
+ // world = world.grow();
|
|
|
|
|
+ // world = world.grow();
|
|
|
|
|
+ // // dbg!(&world);
|
|
|
|
|
+ // world = world.grow();
|
|
|
|
|
+ // // dbg!(&world);
|
|
|
|
|
|
|
|
let opengl = OpenGL::V3_2;
|
|
let opengl = OpenGL::V3_2;
|
|
|
let mut window: PistonWindow =
|
|
let mut window: PistonWindow =
|
|
@@ -102,25 +103,25 @@ fn main() {
|
|
|
let mut step = 0;
|
|
let mut step = 0;
|
|
|
|
|
|
|
|
|
|
|
|
|
- // while let Some(e) = window.next() {
|
|
|
|
|
|
|
+ while let Some(e) = window.next() {
|
|
|
|
|
|
|
|
- // // canvas.put_pixel(step, step, im::Rgba([0, 0, 0, 255]));
|
|
|
|
|
|
|
+ // canvas.put_pixel(step, step, im::Rgba([0, 0, 0, 255]));
|
|
|
|
|
|
|
|
- // let w = world.grow();
|
|
|
|
|
- // world = world.grow();
|
|
|
|
|
|
|
+ let w = world.grow();
|
|
|
|
|
+ world = world.grow();
|
|
|
|
|
|
|
|
- // for (pos, cell) in w.cells {
|
|
|
|
|
- // canvas.put_pixel(pos[0], pos[1], im::Rgba([0, 0, 0, 255]));
|
|
|
|
|
- // }
|
|
|
|
|
|
|
+ for (pos, cell) in w.cells {
|
|
|
|
|
+ canvas.put_pixel(pos[0], pos[1], im::Rgba([0, 0, 0, 255]));
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
- // step += 1;
|
|
|
|
|
|
|
+ step += 1;
|
|
|
|
|
|
|
|
- // texture.update(&mut texture_context, &canvas).unwrap();
|
|
|
|
|
- // window.draw_2d(&e, |c, g, device| {
|
|
|
|
|
- // texture_context.encoder.flush(device);
|
|
|
|
|
|
|
+ texture.update(&mut texture_context, &canvas).unwrap();
|
|
|
|
|
+ window.draw_2d(&e, |c, g, device| {
|
|
|
|
|
+ texture_context.encoder.flush(device);
|
|
|
|
|
|
|
|
- // clear([1.0; 4], g);
|
|
|
|
|
- // image(&texture, c.transform, g);
|
|
|
|
|
- // });
|
|
|
|
|
- // }
|
|
|
|
|
|
|
+ clear([1.0; 4], g);
|
|
|
|
|
+ image(&texture, c.transform, g);
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|