Fix Rendering when no Changes occured

Rendering checks a dirty flag which gets set whenever a cell updates by changing their state.
This commit is contained in:
Marty Oehme 2018-07-07 19:08:26 +02:00
parent 5a10c0e1f7
commit 70e33fe135
2 changed files with 13 additions and 0 deletions

View file

@ -6,11 +6,16 @@ class Cell {
List<Rule> surviveRules = new List<Rule>();
List<Rule> birthRules = new List<Rule>();
/// For determining if render updates are necessary in [Grid].render() function
bool dirty = false;
Cell([bool state = false]) : this.state = state;
void advanceState() {
this.state = this.nextState;
this.nextState = false;
this.dirty = true;
}
void update(int neighbors) {