implemented clear button and reset warning

This commit is contained in:
Max Robinson
2021-12-02 17:27:05 -06:00
parent 77a8b0530b
commit b4ca97902b
2 changed files with 47 additions and 32 deletions

View File

@@ -64,7 +64,7 @@ class WorldEnvironment extends Environment{
}
if (this.organisms.length == 0 && this.auto_reset){
this.reset_count++;
this.reset();
this.reset(false);
}
}
@@ -130,14 +130,19 @@ class WorldEnvironment extends Environment{
}
}
reset() {
reset(confirm_reset=true, reset_life=true) {
if (confirm_reset && !confirm('The current environment will be lost. Proceed?'))
return;
this.organisms = [];
this.grid_map.fillGrid(CellStates.empty);
this.renderer.renderFullGrid(this.grid_map.grid);
this.total_mutability = 0;
this.total_ticks = 0;
FossilRecord.clear_record();
this.OriginOfLife();
if (reset_life)
this.OriginOfLife();
}
resizeGridColRow(cell_size, cols, rows) {