segue todo o projeto : //tamcircle let xCircle = 300; let yCircle = 200; let dCircle = 20; let raio = dCircle / 2;
//velcircle let velXCircle = 3; let velYCircle = -3;
//raquete let xRect1 = 10; let yRect1 = 180; let cRect1 = 5; let aRect1 = 50
//raqueteCPU let xRect2 = 585; let yRect2 = 180; let cRect2 = 5; let aRect2 = 52;
function setup() { createCanvas(600, 400); }
function draw() { background(0); mostracircle (); movimentocircle (); bordas (); mostraraquete (); mostraraquete2 (); movrect1 (); }
function mostracircle (){ circle(xCircle, yCircle, dCircle); }
function movimentocircle (){ xCircle += velXCircle; yCircle += velYCircle; }
function bordas (){ if (xCircle + raio > width || xCircle - raio < 0 ) velXCircle *= -1;
if (yCircle + raio > height || yCircle - raio < 0) velYCircle *= -1;
}
function mostraraquete (){ rect (xRect1, yRect1, cRect1, aRect1) }
function mostraraquete2 (){ rect (xRect2, yRect2, cRect2, aRect2)
}
function movrect1 (){ if (keyIsDown(UP_ARROW)){ yRect1 -= 10 } if (keyIsDown(DOWN_ARROW)){ yRect1 += 10 } }