Hit the Pause button to move the balls.
Click on a ball and move using the mouse.
Click again to stop moving it.
Press Play to start again.
By request, you can now also move the balls with the arrow keys.
You can cut and reattach the balls by hitting the numbers 1 to 5
Noticed that there is sometimes a bit of a speed problem with the sound on.
First wrote something like this over 30 years ago on a 286 machine.
Thank you for all your great comments.
Many have asked how I did this. To answer the question a bit:
Each Ball has an Angle and a Velocity (or energy level). When the angle of a ball becomes greater than the angle of it's neighbour then, in real life, it would have hit the neighbour and would exchange velocities. So I swap the values and, to keep the positions correct, swap the angles. Each time round the loop, it looses a little of the velocity to account for loss of energy. The velocity is also continually being adjusted to account for gravity.