xxxxxxxxxx
54
let x = 0;
let y = 0;
let x2 = 0;
let y2 = 400;
let w = 40;
let h = 40;
let xjump = 2;
let yjump = 3;
let xjump2 = 5;
let yjump2 = -8;
function setup() {
createCanvas(400, 400);
background(100);
}
function draw() {
colorMode(HSB);
fill(
map(x, 0, width, 0, 360),
map(mouseX, 0, width, 0, 100),
map(y, 0, height, 0, 100)
);
rect(x, y, w, h);
x = x + xjump;
y = y + yjump;
if (x >= width || x <= 0) {
xjump = xjump * -1;
}
if (y >= height || y <= 0) {
yjump = yjump * -1;
}
rect(x2, y2, w, h, 20);
x2 = x2 + xjump2;
y2 = y2 + yjump2;
if (x2 >= width || x2 <= 0) {
xjump2 = xjump2 * -1;
}
if (y2 >= height || y2 <= 0) {
yjump2 = yjump2 * -1;
}
//for (let y = h; y < height ; y = y + height/50) {
//for (let x = w; x < width; x = x + width/15) {
//fill(random(140),0,random(135),random(255));
//rect(x, y, w, h,5);
//}
//}
}