Skip to content

Instantly share code, notes, and snippets.

@Chryus
Last active December 23, 2016 18:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Chryus/fba8c60d0770d2cfe8da7d52c0b3b7f3 to your computer and use it in GitHub Desktop.
Save Chryus/fba8c60d0770d2cfe8da7d52c0b3b7f3 to your computer and use it in GitHub Desktop.
example world class importing cell class
// 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