xxxxxxxxxx
35
/*
Can you make a circle that starts at (0, 100) and moves to the right?
Can you make a square that starts at (400, 200) and moves to the left?
Can you make the circle move at a different speed from the rectangle?
Can you make the circle start blue (0, 0, 255) and end up pink (255, 0, 255)?
Can you make the square start with a height of 200 and shrink as it moves to the left?
Can you make the circle move diagonally?
*/
function setup() {
createCanvas(400, 400);
}
let circleX = 0;
let circleY = 0;
let rectX = 400;
let rh = 200;
function draw() {
background(255, 255, 220);
fill(circleX, 0, 255);
ellipse(circleX, circleY, 15, 15);
circleX = circleX + 2;
circleY = circleY + 2;
fill(0, 255, 0);
rect(rectX, 200, 20, rh);
rh = rh - .5;
rectX = rectX - 1;
}