diff --git a/lib/src/Simulation.dart b/lib/src/Simulation.dart index 0955c9a..6a5e3bd 100644 --- a/lib/src/Simulation.dart +++ b/lib/src/Simulation.dart @@ -14,8 +14,7 @@ class Simulation { RuleSet rules = GameOfLife(); - bool _dirty = true; - bool get dirty => _dirty; + bool dirty = true; bool _renderEdges = true; bool get renderEdges => _renderEdges; @@ -38,8 +37,8 @@ class Simulation { Grid reset([Grid map]) { map ??= this.map; - _dirty = true; - map.setAll(0, List.filled(map.length, false)); +// dirty = true; +// map.setAll(0, List.filled(map.length, false)); return map; } @@ -61,7 +60,7 @@ class Simulation { if (sanityCheck > 100 && sanityCheck > i * 3) break; } - _dirty = true; + dirty = true; } void setCellState(int x, int y, bool state) { @@ -91,7 +90,7 @@ class Simulation { void mergeStateChanges(Map stateChanges) { stateChanges.forEach((i, el) => map[i] = el); - if (stateChanges.length != 0) _dirty = true; + if (stateChanges.length != 0) dirty = true; } Map calculateNextState(Grid oldState) { @@ -127,7 +126,7 @@ class Simulation { void render(html.CanvasElement canvas, [num interp]) { // only renders if any cells changed between renders - if (!_dirty) return; + if (!dirty) return; html.CanvasRenderingContext2D ctx = canvas.getContext('2d'); int brickW = (canvas.width ~/ map.width); @@ -146,18 +145,18 @@ class Simulation { ctx.setFillColorRgb(0, 0, 0); ctx.fillRect(p.x * brickW, p.y * brickH, brickW, brickH); } - _dirty = false; + dirty = false; } void set renderEdges(bool on) { _renderEdges = on; - _dirty = true; + dirty = true; } void saveSnapshot() => _snapshot = Grid.from(map); Grid loadSnapshot() { map = Grid.from(_snapshot); - _dirty = true; + dirty = true; return map; } }