xxxxxxxxxx
39
/*
Animation "3 times faster"
*/
let x = 200
let y = 200
let xSpeed = 30
let ySpeed = 30
function mousePressed(){
save('3 times faster.jpg')
}
function setup() {
createCanvas(500, 400);
}
function draw() {
background(220);
// Draw the circle
noStroke()
circle(x, y, 20)
fill("red")
//Animate the circle
x = x + xSpeed * 3
y = y + ySpeed * 3
//Bounce off of X-coordinates
if(x > width || x < 0){
xSpeed = xSpeed * -1
}
//Bounce off of Y-coordinates
if(y > height || y < 0){
ySpeed = ySpeed * -1
}
}