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:
parent
5a10c0e1f7
commit
70e33fe135
2 changed files with 13 additions and 0 deletions
|
|
@ -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) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue