xxxxxxxxxx
var bbx;
var bby;
var diam;
var bx;
var by;
function setup() {
createCanvas(600, 600);
bbx = width / 2;
bby = height / 2;
diam = 50;
bx = 3.1;
by = 1.2;
}
function draw() {
background(0, 0, 0, 20);
stroke("pink");
strokeWeight(2);
fill("pink");
ellipse(bbx, bby, diam, diam);
bbx = bbx + bx;
bby = bby + by;
var radius = diam / 2;
if (bbx > width - radius) {
bx = 0 - bx;
}
if (bby > height - radius) {
by = 0 - by;
}
if (bbx < radius) {
bx = 0 - bx;
}
if (bby < radius) {
by = 0 - by;
}
}