edit mode fixes

This commit is contained in:
MaxRobinsonTheGreat
2020-07-22 12:07:27 -06:00
parent c94e137ae4
commit b0292ae0e6
10 changed files with 152 additions and 390 deletions

View File

@@ -18,6 +18,8 @@ class Environment{
this.walls = [];
this.total_mutability = 0;
this.auto_reset = true;
this.largest_cell_count = 0;
this.reset_count = 0;
}
update(delta_time) {
@@ -41,8 +43,10 @@ class Environment{
this.total_mutability -= this.organisms[i].mutability;
this.organisms.splice(i, 1);
}
if (this.organisms.length == 0 && this.auto_reset)
if (this.organisms.length == 0 && this.auto_reset){
this.reset_count++;
this.reset();
}
}
OriginOfLife() {
@@ -58,6 +62,8 @@ class Environment{
organism.updateGrid();
this.total_mutability += organism.mutability;
this.organisms.push(organism);
if (organism.cells.length > this.largest_cell_count)
this.largest_cell_count = organism.cells.length;
}
averageMutability() {
@@ -75,8 +81,10 @@ class Environment{
}
clearWalls() {
for(var wall of this.walls)
this.changeCell(wall.col, wall.row, CellTypes.empty, null);
for(var wall of this.walls){
if (this.grid_map.cellAt(wall.col, wall.row).type == CellTypes.wall)
this.changeCell(wall.col, wall.row, CellTypes.empty, null);
}
}
clearOrganisms() {
@@ -85,7 +93,7 @@ class Environment{
this.organisms = [];
}
reset() {
reset(clear_walls=true) {
this.organisms = [];
this.grid_map.fillGrid(CellTypes.empty);
this.renderer.renderFullGrid(this.grid_map.grid);

View File

@@ -8,8 +8,8 @@ const Cell = require("../Organism/Cell/Cell");
class OrganismEditor {
constructor() {
this.is_active = true;
var cell_size = 20;
this.grid_map = new GridMap(11, 11, cell_size);
var cell_size = 13;
this.grid_map = new GridMap(15, 15, cell_size);
this.renderer = new Renderer('editor-canvas', 'editor-env', cell_size);
this.controller = new EditorController(this, this.renderer.canvas);
this.clear();