xxxxxxxxxx
58
let x;
let y;
let d; // direction x
let c; // colour
let r; // radius
let b; // background
let h; // direction y
let r2;
function setup() {
createCanvas(800, 800);
x = 30
y = 200
d = +5
c = -255
r = 70
r2 = 20
b = 200
h = +1
}
function draw() {
background(0, b ,b);
noStroke()
fill(c)
ellipse(x, y, r, r2);
fill(-c)
textSize(15)
textAlign(CENTER);
text ("DVD", x, y+4)
x = x+d
y = y+h
if (x > (r/2)-1 && x < width-(r/2)) {
c = c;
d = d;
}
else {
c = -c;
d = -d;
}
if (y > (r2/2)-1 && y < height-(r2/2)) {
h = h;
c = c;
}
else {
h = -h
c = -c;
}
}