Create a New Scene with a CharacterBody2D as the Root.
Add a Sprite2D as a child and use the Ball.png as the texture.
Add a CollisionShape2D with a New Circle Shape
Enclose the ball with the circle.
Add a Script to the Ball.
There are two values which we want to experiment with from within the editor.
initial_ball_speed and speed_multiplier
In this case we are increasing the speed by 2% after every bounce.
Now set the ball_speed to the initial_speed
In the _ready() function we will launch the ball
Create the launch_ball() function
Call Randomize() to get a different random number each time
Generate a random x direction of 1 or -1
Generate a random y direction of 0.8 or -0.8
Move ball in the chosen direction at initial speed
Moving the ball and detecting collisions is done in the _physics_process function
First move the ball and record the details of any collision
Get the perpendicular direction of the surface the ball collided with
Bounce the ball off of that surface in the opposite direction
Increase the speed of the ball by the multiplier variable.
Now add the ball to your Board
Position the ball at the centre of the board.