let xBall = 300; let yBall = 200; let diametro = 20; let xSpeedball = 7; let ySpeedball = 7; let raio = diametro / 2
function setup() { createCanvas(600, 400); }
function draw() { background(0); showball() speedball() variableball() }
function showball(){ circle(xBall,yBall,diametro) }
function speedball(){ xBall += xSpeedball yBall += ySpeedball }
function variableball(){ if (xBall + raio>width|| xBall<0 ){ xSpeedball=-1 } if (yBall + raio>height|| yBall<0 ){ ySpeedball=-1 } }