Add Simulation Saving and Loading Methods
This commit is contained in:
parent
befb345ddd
commit
0da2d08b74
2 changed files with 16 additions and 0 deletions
|
|
@ -10,6 +10,8 @@ enum CellPattern { SpaceShip, Blinker }
|
|||
|
||||
class Simulation {
|
||||
Grid<bool> map;
|
||||
Grid<bool> _snapshot;
|
||||
|
||||
RuleSet rules = GameOfLife();
|
||||
|
||||
bool _dirty = true;
|
||||
|
|
@ -151,4 +153,7 @@ class Simulation {
|
|||
_renderEdges = on;
|
||||
_dirty = true;
|
||||
}
|
||||
|
||||
void saveSnapshot() => _snapshot = map;
|
||||
Grid<bool> loadSnapshot() => map = _snapshot;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue