xxxxxxxxxx
45
let v;
function setup() {
createCanvas(400, 400);
rectMode(CENTER);
noStroke();
fill(0,80);
v = createVector(width/2, height/2);
}
function draw() {
// background(220);
snake2();
circle(v.x, v.y, random(10));
let r = random();
if(r > 0.75){
// aller Nord
v.y = v.y - 10;
}
else if ( r > 0.5){
v.x = v.x + 10;
}
else if( r > 0.25){
v.y = v.y + 10;
}
else{
v.x = v.x - 10;
}
}
function snake2(){
if(v.x > width){
v.x = 0;
}
if(v.x < 0) {
v.x = width;
}
if(v.y < 0) {
v.y = height;
}
if(v.y > height){
v.y =0
}
}