Fix Reset & Step not working on first click
Rendering dirty flags were not updated accordingly, so the updates happened but were not pushed to be rendered. Added and moved additional dirty flag setters.
This commit is contained in:
parent
2d2365e606
commit
c5b62e6c9f
3 changed files with 10 additions and 4 deletions
|
@ -44,6 +44,7 @@ class AppComponent implements OnInit {
|
||||||
}
|
}
|
||||||
|
|
||||||
void onResetClicked() {
|
void onResetClicked() {
|
||||||
|
engine.running = false;
|
||||||
engine.reset();
|
engine.reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -24,12 +24,13 @@ class App {
|
||||||
|
|
||||||
App(this.canvas) {
|
App(this.canvas) {
|
||||||
_elapsed.start();
|
_elapsed.start();
|
||||||
grid.startingPattern();
|
grid.addPattern(amount: 15, dispersal: 5);
|
||||||
}
|
}
|
||||||
|
|
||||||
void reset() {
|
void reset() {
|
||||||
grid = new Grid(100, 100);
|
// grid = new Grid(100, 100);
|
||||||
running = false;
|
// running = false;
|
||||||
|
grid.reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
void process(num now) {
|
void process(num now) {
|
||||||
|
|
|
@ -89,6 +89,10 @@ class Grid {
|
||||||
if (y < map.length && x < map[y].length) map[y][x].state = state;
|
if (y < map.length && x < map[y].length) map[y][x].state = state;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool getCellState(int x, int y) {
|
||||||
|
if (y < map.length && x < map[y].length) return map[y][x].state;
|
||||||
|
}
|
||||||
|
|
||||||
List<List<Cell>> _buildGrid(int w, int h) {
|
List<List<Cell>> _buildGrid(int w, int h) {
|
||||||
print("grid being created");
|
print("grid being created");
|
||||||
List<List<Cell>> grid = new List(h);
|
List<List<Cell>> grid = new List(h);
|
||||||
|
@ -133,13 +137,13 @@ class Grid {
|
||||||
for (int x = 0; x < w; x++) {
|
for (int x = 0; x < w; x++) {
|
||||||
// DEFAULTS TO CONWAY GAME OF LIFE RANGE OF ONE
|
// DEFAULTS TO CONWAY GAME OF LIFE RANGE OF ONE
|
||||||
map[y][x].update(getSurroundingNeighbors(x, y, 1));
|
map[y][x].update(getSurroundingNeighbors(x, y, 1));
|
||||||
if (!_dirty && map[y][x].dirty) _dirty = true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (int y = 0; y < h; y++) {
|
for (int y = 0; y < h; y++) {
|
||||||
for (int x = 0; x < w; x++) {
|
for (int x = 0; x < w; x++) {
|
||||||
// DEFAULTS TO CONWAY GAME OF LIFE RANGE OF ONE
|
// DEFAULTS TO CONWAY GAME OF LIFE RANGE OF ONE
|
||||||
map[y][x].advanceState();
|
map[y][x].advanceState();
|
||||||
|
if (!_dirty && map[y][x].dirty) _dirty = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue