xxxxxxxxxx
22
let position, velocity;
function setup() {
velocity = createVector(5,0);
position = createVector(200,50);
createCanvas(400, 400);
}
function draw() {
background(220);
velocity.y += 1;
position.add(velocity);
if (position.y > 360) {
velocity.y = velocity.y * -1;
}
if (position.x < 40 || position.x > 360) {
velocity.x = velocity.x * -1;
}
ellipse(position.x, position.y, 80,80);
}