The following program displays a ball that keeps bouncing around on the screen. This program has been created using the BGI library functions and compiled with the Turbo C++ 3.0 IDE. To learn more about BGI Graphics and its functions, read How to Create Graphical Applications using Turbo C++ 3.0 IDE (BGI library).
As you can in the above images, the ball keeps bouncing from side of the screen to another. You can modfiy the ball’s size, colour and speed as well as the background colour. The motion of the ball around the screen produces a nice animation. And if you customize all the things to your desired condition, it would be even better. Whenever the ball touches one of the walls, a beep sound is made, indicating that a collision has taken place.
Download the source code or the executable of the program (as per your requirement) and let us know if you like it.