renaming main to index and minor changes

This commit is contained in:
Ole Morud
2021-01-25 15:37:05 +01:00
parent 60a6c4437a
commit 961a592f3b
2 changed files with 5 additions and 7 deletions

12
main.js
View File

@@ -1,6 +1,6 @@
//Game options
var framerate = 10;
var framerate = 150;
var gColumns = 60;
var gRows = 140;
var tileWidth = 12;
@@ -24,12 +24,9 @@ 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){
@@ -69,6 +66,7 @@ var tiles = {
}
}
//Initializes canvas and event listeners (starts when HTML has loaded)
function startGame() {
myGameArea.start();