Ao invés da raquete subir e descer ela esta se movimentando para os lados.
//var bolinha let xbolinha = 300; let ybolinha = 200; let diametro = 15; let raio = diametro/2;
//var velocidade let xvelocidade = 5; let yvelocidade = 5;
//var raquete let xRaquete = 5; let yRaquete = 5; let wRaquete = 10; let hRaquete = 80;
function setup (){ createCanvas(600, 400); }
function draw (){ background(0); mostraBolinha(); moverBolinha(); bordaColisao(); mostraRaquete(); movimentaRaquete();
function mostraBolinha (){ circle(xbolinha, ybolinha, diametro); return }
function moverBolinha (){ xbolinha += xvelocidade; ybolinha += yvelocidade; }
function bordaColisao (){ if (xbolinha + raio > width || xbolinha - raio < 0){ xvelocidade *= -1; }
if (ybolinha + raio > height || ybolinha - raio < 0){ yvelocidade *= -1; } } }
function mostraRaquete(){ rect(yRaquete, xRaquete, wRaquete, hRaquete);
}
function movimentaRaquete(){ if (keyIsDown(UP_ARROW)){ yRaquete -= 10; } if (keyIsDown(DOWN_ARROW)){ yRaquete += 10; } }