xxxxxxxxxx
39
var x = 150;
var y = 200;
function setup() {
createCanvas(400, 400);
}
function draw() {
background(0);
ellipse(x,y,40,40);
if (x < mouseX){
x = x + random(-4,6);
}
else{
x = x + random(-6,4);
}
if (y < mouseY){
y = y + random(-4,6);
}
else{
y = y + random(-6,4);
}
if (mouseIsPressed === true){
x = 200;
y = 200;
}
if (x < 20){
x = 20;
}
if (x > 400-20){
x = 400-20;
}
if (y < 20){
y = 20;
}
if (y > 400-20){
y = 400-20;
}
}