Solucionado (ver solução)
Solucionado
(ver solução)
1
resposta

Tudo funcional. Buscando codar de forma limpa e eficiente.

//about the Ball
let xBoll = 100;
let yBoll = 100;
let diameter = 30;
let radius = diameter / 2;

//speed of the Ball
let speedXBoll = 6;
let speedYBoll = 6;

//game arena
function setup() {
  createCanvas(600, 400);
}

//master function
function draw() {
  background(0);
  showBall();
  moveBall();
  collisionBall(); 
}

//control functions
function showBall(){
  circle(xBoll, yBoll, diameter);
}

function moveBall(){
  xBoll += speedXBoll;
  yBoll += speedYBoll;
}

function collisionBall(){
  if (xBoll + radius > width || xBoll - radius < 0) {
    speedXBoll *= -1;
  }

  if (yBoll + radius > height || yBoll - radius < 0) {
    speedYBoll *= -1;
  }
}
1 resposta
solução!

Boa noite, Eliezer! Como vai?

Bacana! Agora é seguir em frente rumo à luz do conhecimento! E sempre que precisar de alguma ajuda é só mandar aqui no fórum da Alura!

Grande abraço e bons estudos, meu aluno!