public static void Update() { if (Width == null || Height == null) { return; } for (var x = 0; x < Width; x++) { for (var y = 0; y < Height; y++) { if (CurrentGeneration[x][y] != NextGeneration[x][y]) { ViewPort.SetTile(x, y, (CurrentGeneration[x][y] = NextGeneration[x][y])); } } } }
public static void SetSize(int width, int height, bool repaint = true) { if (width < 1 && height < 1) { return; } var set = NextGeneration != null && repaint; bool[][] old = null; if (set) { old = NextGeneration; } CurrentGeneration = new bool[width][]; for (var x = 0; x < width; x++) { CurrentGeneration[x] = new bool[height]; } NextGeneration = new bool[width][]; for (var x = 0; x < width; x++) { NextGeneration[x] = new bool[height]; } if (set) { for (var x = 0; x < old.Length && x < NextGeneration.Length; x++) { for (var y = 0; y < old[0].Length && y < NextGeneration[0].Length; y++) { NextGeneration[x][y] = old[x][y]; } } } ViewPort.Create(); }