attempt to fix ugly indentation from notepad++
This commit is contained in:
@@ -7,7 +7,6 @@
|
||||
canvas {
|
||||
border:1px solid #7f7f7f;
|
||||
background-color: #ffffff;
|
||||
|
||||
}
|
||||
.center {
|
||||
display: block;
|
||||
|
||||
21
main.js
21
main.js
@@ -1,4 +1,3 @@
|
||||
|
||||
//Game options
|
||||
var framerate = 150;
|
||||
var gColumns = 60;
|
||||
@@ -24,9 +23,15 @@ var tiles = {
|
||||
//Create temporary 2D array of new values
|
||||
for (var x = 0; x < gRows; x++)
|
||||
for (var y = 0; y < gColumns; y++) {
|
||||
if(![2,3].includes(this.getNeighbors(x,y))){ this.tempTiles[x][y] = 0; } //cell dies if number of neighbors are not 2 or 3
|
||||
else if(this.getNeighbors(x,y) == 3) { this.tempTiles[x][y] = 1; } //cell is born if there are exactly 3 neighbors
|
||||
else { this.tempTiles[x][y] = this.tiles[x][y]; } //cell remains unchanged otherwise
|
||||
if (![2, 3].includes(this.getNeighbors(x, y))) {
|
||||
this.tempTiles[x][y] = 0;
|
||||
} //cell dies if number of neighbors are not 2 or 3
|
||||
else if (this.getNeighbors(x, y) == 3) {
|
||||
this.tempTiles[x][y] = 1;
|
||||
} //cell is born if there are exactly 3 neighbors
|
||||
else {
|
||||
this.tempTiles[x][y] = this.tiles[x][y];
|
||||
} //cell remains unchanged otherwise
|
||||
|
||||
//Draw new graphics
|
||||
if (this.tempTiles[x][y] == 1) {
|
||||
@@ -35,9 +40,11 @@ var tiles = {
|
||||
}
|
||||
|
||||
//Replace old values with new values
|
||||
for(var x=0; x<gRows; x++)
|
||||
for(var y=0; y<gColumns; y++)
|
||||
for (var x = 0; x < gRows; x++) {
|
||||
for (var y = 0; y < gColumns; y++) {
|
||||
this.tiles[x][y] = this.tempTiles[x][y];
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
//returns number of neighboring cells for cell at position x, y
|
||||
@@ -138,7 +145,7 @@ function drawGrid(columns, rows, size){
|
||||
ctx.lineWidth = 1;
|
||||
ctx.strokeStyle = "#7F7F7F";
|
||||
|
||||
//By adding 0.5 we go from 2px width to 1px width
|
||||
//By adding 0.5 the lines are displayed sharper
|
||||
for (var i = 1; i <= columns; i++) {
|
||||
ctx.moveTo(0, i * size + 0.5);
|
||||
ctx.lineTo(canvas_width, i * size + 0.5);
|
||||
|
||||
Reference in New Issue
Block a user