Rename var in a function (can you tell I do not want to add UI)

This commit is contained in:
shoe 2025-03-21 22:21:43 +00:00
parent f8f9934833
commit 25629dd65e

View File

@ -83,20 +83,21 @@ function update_walkers() {
}
}
function add_random_direction(pos) {
// give this function a walker and it will update the walkerition by one tile
function add_random_direction(walker) {
let rand = Math.floor(Math.random() * 4);
if (rand === 0) {
pos.row++;
pos.row = pos.row.mod(n_rows);
walker.row++;
walker.row = walker.row.mod(n_rows);
} else if (rand === 1) {
pos.row--;
pos.row = pos.row.mod(n_rows);
walker.row--;
walker.row = walker.row.mod(n_rows);
} else if (rand === 2) {
pos.col++;
pos.col = pos.col.mod(n_cols);
walker.col++;
walker.col = walker.col.mod(n_cols);
} else {
pos.col--;
pos.col = pos.col.mod(n_cols);
walker.col--;
walker.col = walker.col.mod(n_cols);
}
}