xxxxxxxxxx
42
let velocity2= 0.8;
let velocity= 1.7;
let offset = 0;
let offset2 =0 ;
let w = 0;
let h = 0;
function setup() {
createCanvas(600, 600);
background(220, 220,220);
}
function draw() {
fill(0);
offset = velocity + offset;
offset2 = velocity2 + offset2;
background(220, 220,220,30);
w = 0 + offset;
h = 0 + offset2;
ellipse(w, h, 50);
var constx = constrain(mouseX,0, width);
var consty = constrain(mouseY,0, width);
rect(constx,0, 100, 20);
rect(0,constrain(mouseY,0, width), 20, 100);
rect(constx,width-20, 100, 20);
rect(height-20,constrain(mouseY,0, width), 20, 100);
if(((h >= consty)&&(h <= consty + 100))&&((w > width - 20)&&(w <= width + 20))){
velocity = -velocity;
}
if(((w >= constx)&&(w <= constx + 100))&&((h > height - 20)&&(h <= height + 20))){
velocity2 = -velocity2;
}
if(((h >= consty)&&(h <= consty + 100))&&((w > - 20)&&(w < +20))){
velocity = -velocity;
}
if(((w >= constx)&&(w <= constx + 100))&&((h > - 20)&&(h < +20))){
velocity2 = -velocity2;
}
}