HOME PROJECTS DEMOS TUTORIALS JOBASE
info@greyhope.uk

Ball Physics

Edit the code to change the result above.

In this demo, I have tried to make the code as minimal as possible. The main collision calculations are done inside the update function.

To find the distance between two circles, you need to use the Pythagoras Theorem. The example below will show how this is achieved. Once you have the distance, it's easy to calculate collision.

distance = √(x-distance² + y-distance²)

Feel free to fiddle with the code and make your own combinations.