rm new
This commit is contained in:
@@ -1,17 +1,19 @@
|
||||
function grid(w, h) {
|
||||
this.width = w;
|
||||
this.height = h;
|
||||
var newgrid = meme(grid_prototype)
|
||||
newgrid.width = w;
|
||||
newgrid.height = h;
|
||||
// create a height×width array of empty lists
|
||||
this.cells = array(h);
|
||||
newgrid.cells = array(h);
|
||||
for (var y = 0; y < h; y++) {
|
||||
this.cells[y] = array(w);
|
||||
newgrid.cells[y] = array(w);
|
||||
for (var x = 0; x < w; x++) {
|
||||
this.cells[y][x] = []; // each cell holds its own list
|
||||
newgrid.cells[y][x] = []; // each cell holds its own list
|
||||
}
|
||||
}
|
||||
return newgrid
|
||||
}
|
||||
|
||||
grid.prototype = {
|
||||
var grid_prototype = {
|
||||
// return the array at (x,y)
|
||||
cell(x, y) {
|
||||
return this.cells[y][x];
|
||||
@@ -66,4 +68,6 @@ grid.prototype = {
|
||||
}
|
||||
return out;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
return grid
|
||||
|
||||
Reference in New Issue
Block a user