xxxxxxxxxx
41
let left, right, upper, bottom;
let x;
let y;
function setup() {
createCanvas(800, 400);
x=width/2;
y= height/2;
}
function draw() {
background(0, mouseX, mouseY);
fill(mouseX, mouseY, 0);
rectMode(CENTER);
stroke(255);
// question 2
// rect(width/2, height/2, width/2, height/2);
//CHALLENGE 7
rect(x, y, width/2, height/2);
let xSpeed= (mouseX- x)/200
let ySpeed= (mouseY- y)/200
x += xSpeed
y += ySpeed
//question 3
// left= width/4;
// right= 3/4 * width;
// upper= height/4;
// bottom= 3/4 * height
// line(left, upper, right, upper);
// line(right, upper, right, bottom);
// line(right, bottom, left, bottom);
// line(left, bottom, left, upper);
}