xxxxxxxxxx
56
let x = 50;
let w;
let y = 50;
let h;
let rSize = 50;
let xJump = 5;
let yJump = 5;
var c;
var s;
function setup() {
cnv= createCanvas(windowWidth, windowHeight);
background(19,19,19);
frameRate(100);
rectMode(CENTER);
//cnv.mousePressed(changeColor);
s=10; // which is the size of rect
c=255; //color of rect
//fill(30,20);
//stroke(5);
}
function draw() {
background(19,19,19);
if (mouseX > x || mouseX < x + w || mouseY > y || mouseY < y + h);
rect(x, y, 25,25,s,s);
if (x > width - 12.5) {
xJump = xJump * -1;
}
if (x < 12.5) {
xJump = xJump * -1;
}
if (y > height - 12.5) {
yJump = yJump * -1;
}
if (y < 12.5) {
yJump = yJump * -1;
}
x = x + xJump;
y = y + yJump;
}
// function mousePressed() {
// s = s + 0;
// }
// function changeColor() {
// colorMode(RGB);
// c = random(0,365);
// }