xxxxxxxxxx
32
let x;
let y;
function setup() {
createCanvas(600, 600);
x = 200;
y = 200;
for (let i = 0; i <10000; i++){
draw();
}
}
function draw() {
//background(220);
strokeWeight(10);
stroke('purple');
point(x,y);
let randomValue = random();
if (randomValue < 0.25) {
x--; // x -= 1
}
else if (randomValue < 0.5) {
x++; // x += 1
}
else if (randomValue < 0.75) {
y--;
}
else {
y++;
}
}