xxxxxxxxxx
42
let x = 200;
let y = 200;
let w = 40;
let h = 40;
let xjump = 3;
let yjump = 5;
function setup() {
createCanvas(400,400);
}
function draw() {
background(100);
colorMode(HSB);
strokeWeight(3);
stroke(
map(x,0,width,0,360),
map(mouseX,0,width,0,100),
map(y,0,height,0,100)
);
rect(x,y,w,h);
// crazy movement
// x = x + random(-30, 30);
// y = y + random( -30, 30);
// if(x > width || y > height || x < 0 || y < 0){
// x = 20;
// y = 20;}
x = x + xjump;
y = y + yjump;
if(x >= width || x <= 0){
xjump = xjump * -1;
fill(180, 80, random(255))
}
if(y >= height || y <= 0){
yjump = yjump * -1;
fill(330, 80, random(255))
}
}