xxxxxxxxxx
43
let rSize=30;
let x = 3;
let y = 0;
let xJump= 2;
let yJump= 2.1;
function setup() {
createCanvas(400, 400);
background(255);
frameRate(100);
rectMode (CENTER);
fill(30,20);
stroke(5);
}
function draw() {
colorMode(RGB);
fill(
map(x,0,width,0,200),
100,
map(y,0,height,100,300),
map(mouseX,0,width,0,50),
map(mouseY,0,height,50,1)
);
rect(x, y, 25, 25);
x = x + xJump;
y = y + yJump;
if (x > width) {
xJump = xJump * -1;
}
if (x <= 0) {
xJump = xJump * -1;
}
if (y > height) {
yJump = yJump * -1;
}
if (y <= 0) {
yJump = yJump * -1;
}
}