xxxxxxxxxx
22
let loc;
let vel;
function setup() {
createCanvas(400, 400);
loc = createVector(width/2, height/2);
vel = createVector(2.0, 3.0);
}
function draw() {
background(220);
if (loc.x > width || loc.x < 0) {
vel.x *= -1;
}
if (loc.y > height || loc.y < 0) {
vel.y *= -1;
}
ellipse(loc.x, loc.y, 15, 15)
loc.add(vel)
}