//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;
}
}