xxxxxxxxxx
52
let rad = 100;
let xpos = 300;
let xspeed = 15;
let xdirection = 1;
let ypos = 300;
let yspeed = 10;
let ydirection = 1;
let circRed = 50;
let circGreen = 50;
let circBlue = 50;
function setup() {
createCanvas(800, 800);
}
function draw() {
background('black');
noStroke();
fill(circRed,circGreen,circBlue);
ellipse(xpos,ypos,rad*2,rad*2);
if (xpos >= width - rad || xpos <= rad) {
xdirection = xdirection * -1;
circRed = random(0,255);
circGreen = random(0,255);
circBlue = random(0,255);
}
xpos = xpos + xspeed * xdirection;
if (ypos >= width - rad || ypos <= rad) {
ydirection = ydirection * -1;
circRed = random(0,255);
circGreen = random(0,255);
circBlue = random(0,255);
}
ypos = ypos + yspeed * ydirection;
// print(xpos);
}