random ball
var rad = 50;
var xpos, ypos;
var xspeed =20.3;
var yspeed =20.3;
var xdirection = 1;
var ydirection = 1;
function setup() {
createCanvas(windowWidth,
windowHeight);
noStroke();
ellipseMode(RADIUS);
xpos = width / 2;
ypos = height / 2;
}
function draw() {
background(234, 234, 234);
xpos = xpos + xspeed * xdirection;
ypos = ypos + yspeed * ydirection;
if (xpos > width - rad || xpos < rad) {
xdirection *= -1;
}
if (ypos > height - rad || ypos < rad) {
ydirection *= -1;
}
ellipse(xpos, ypos, rad, rad);
fill(80, 30, 100);
ellipse(random(xpos-5), random(ypos-5), random(15,50),random(15,50));
fill(random(150,250),random(50,100),random(80,130));
}