// Cloned by Cbum on 29 Nov 2022 from World "Snake randomly crawling on a 2D grid" by Marko
// Please leave this clone trail here.
const leftCornerX = -100;
const leftCornerY = -100;
const rectSize = 10;
const nrFields = 10;
const snakeLen = 0;
var snake = Array(snakeLen);
for(var i = 0; i < snakeLen; i++) {
snake[i] = [i, 0];
}
function isSnakeField(x, y) {
for(var i = 0; i < snakeLen; i++) {
const snakeField = snake[i];
if(snakeField[0] === x && snakeField[1] === y) {
return true;
}
}
return false;
}
function setup() // "setup" is called once at start of run
{
createCanvas ( ABWorld.fullwidth(), ABWorld.fullheight(), WEBGL );
}
function draw() // "draw" is called every timestep during run
{
background("lightblue");
for(var i = 0; i < nrFields; i++) {
for(var j = 0; j < nrFields; j++) {
var color = isSnakeField(i, j) ? "black" : "white";
fill(color);
rect(leftCornerX + rectSize * i, leftCornerY + rectSize * j, rectSize, rectSize);
}
}
moveSnake();
}