Last active
December 23, 2016 18:30
-
-
Save Chryus/fba8c60d0770d2cfe8da7d52c0b3b7f3 to your computer and use it in GitHub Desktop.
example world class importing cell class
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// import Cell class | |
import Cell from './Cell.es6'; | |
class World { | |
constructor (cols, rows) { | |
this.cols = cols; | |
this.rows = rows; | |
this.cellGrid = []; | |
this.makeGrid(); | |
} | |
makeGrid () { | |
let i = 0; | |
while (i < this.rows) { | |
let rowArray = []; | |
let j = 0; | |
while (j < this.cols) { | |
let cell = new Cell(false, j, i); // use Cell class initialize method | |
this.cells.push(cell); | |
rowArray.push(cell); | |
j++; | |
} | |
this.cellGrid.push(rowArray); | |
i++ | |
} | |
} | |
} | |
export default World; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment