fix syntax

This commit is contained in:
2026-02-17 09:15:15 -06:00
parent f310c18b84
commit 4e1b63fd0e
52 changed files with 2169 additions and 1754 deletions

View File

@@ -2,11 +2,13 @@ function grid(w, h) {
var newgrid = meme(grid_prototype)
newgrid.width = w;
newgrid.height = h;
// create a height×width array of empty lists
// create a height*width array of empty lists
newgrid.cells = array(h);
for (var y = 0; y < h; y++) {
var y = 0;
var x = 0;
for (y = 0; y < h; y++) {
newgrid.cells[y] = array(w);
for (var x = 0; x < w; x++) {
for (x = 0; x < w; x++) {
newgrid.cells[y][x] = []; // each cell holds its own list
}
}
@@ -45,9 +47,12 @@ var grid_prototype = {
// call fn(entity, coord) for every entity in every cell
each(fn) {
for (var y = 0; y < this.height; y++) {
for (var x = 0; x < this.width; x++) {
def list = this.cells[y][x]
var list = null;
var y = 0;
var x = 0;
for (y = 0; y < this.height; y++) {
for (x = 0; x < this.width; x++) {
list = this.cells[y][x]
arrfor(list, function(entity) {
fn(entity, entity.coord);
})
@@ -57,9 +62,11 @@ var grid_prototype = {
// printable representation
toString() {
var out = `grid [${this.width}×${this.height}]\n`;
for (var y = 0; y < this.height; y++) {
for (var x = 0; x < this.width; x++) {
var out = `grid [${this.width}x${this.height}]\n`;
var y = 0;
var x = 0;
for (y = 0; y < this.height; y++) {
for (x = 0; x < this.width; x++) {
out += length(this.cells[y][x]);
}
if (y != this.height - 1) out += "\n";