var -> let
This commit is contained in:
@@ -57,19 +57,19 @@ class EnvironmentController extends CanvasController{
|
|||||||
*/
|
*/
|
||||||
randomizeWalls(thickness=1) {
|
randomizeWalls(thickness=1) {
|
||||||
this.env.clearWalls();
|
this.env.clearWalls();
|
||||||
var noise_threshold = -0.017;
|
const noise_threshold = -0.017;
|
||||||
var avg_noise = 0;
|
let avg_noise = 0;
|
||||||
var resolution = 20;
|
let resolution = 20;
|
||||||
Perlin.seed();
|
Perlin.seed();
|
||||||
|
|
||||||
for (var r = 0; r < this.env.num_rows; r++) {
|
for (let r = 0; r < this.env.num_rows; r++) {
|
||||||
for (var c = 0; c < this.env.num_cols; c++) {
|
for (let c = 0; c < this.env.num_cols; c++) {
|
||||||
var xval = c/this.env.num_cols*(resolution/this.env.renderer.cell_size*(this.env.num_cols/this.env.num_rows));
|
let xval = c/this.env.num_cols*(resolution/this.env.renderer.cell_size*(this.env.num_cols/this.env.num_rows));
|
||||||
var yval = r/this.env.num_rows*(resolution/this.env.renderer.cell_size*(this.env.num_rows/this.env.num_cols));
|
let yval = r/this.env.num_rows*(resolution/this.env.renderer.cell_size*(this.env.num_rows/this.env.num_cols));
|
||||||
var noise = Perlin.get(xval, yval);
|
let noise = Perlin.get(xval, yval);
|
||||||
avg_noise += noise/(this.env.num_rows*this.env.num_cols);
|
avg_noise += noise/(this.env.num_rows*this.env.num_cols);
|
||||||
if (noise > noise_threshold && noise < noise_threshold + thickness/resolution) {
|
if (noise > noise_threshold && noise < noise_threshold + thickness/resolution) {
|
||||||
var cell = this.env.grid_map.cellAt(c, r);
|
let cell = this.env.grid_map.cellAt(c, r);
|
||||||
if (cell != null) {
|
if (cell != null) {
|
||||||
if(cell.owner != null) cell.owner.die();
|
if(cell.owner != null) cell.owner.die();
|
||||||
this.env.changeCell(c, r, CellStates.wall, null);
|
this.env.changeCell(c, r, CellStates.wall, null);
|
||||||
@@ -80,7 +80,6 @@ class EnvironmentController extends CanvasController{
|
|||||||
}
|
}
|
||||||
|
|
||||||
updateMouseLocation(offsetX, offsetY){
|
updateMouseLocation(offsetX, offsetY){
|
||||||
|
|
||||||
super.updateMouseLocation(offsetX, offsetY);
|
super.updateMouseLocation(offsetX, offsetY);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -104,7 +104,7 @@ class WorldEnvironment extends Environment{
|
|||||||
|
|
||||||
clearWalls() {
|
clearWalls() {
|
||||||
for(var wall of this.walls){
|
for(var wall of this.walls){
|
||||||
var wcell = this.grid_map.cellAt(wall.col, wall.row);
|
let wcell = this.grid_map.cellAt(wall.col, wall.row);
|
||||||
if (wcell && wcell.state == CellStates.wall)
|
if (wcell && wcell.state == CellStates.wall)
|
||||||
this.changeCell(wall.col, wall.row, CellStates.empty, null);
|
this.changeCell(wall.col, wall.row, CellStates.empty, null);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user