In my first tutorial, i will try to explain a simple example. Sorry about my english and if you want to see all of this in spanish, you can try in my personal blog www.alejandroquarto.com.

Note: possibly, this is not the best way to do it, you can always improve my code. Anyway i want to keep it simple for learning, for those that are not the best coders in the world and that may want to get nice results in a few hours.

This is one of the possible results that you can get by doing this tutorial:

Basically we have a chain composed with an X amount of balls. The first one is always following the mouse pointer, then one after the other, will follow the next ball.

It seems simple, anyway, the complex part in this example is to be able to handle all the balls collision. So, we have to detect overlapping between balls and try to correct each position.

We will need to calculate distance between points for a lot of things in this example, so first, let's try to extend the Math class by adding some new useful methods. This will help you in the future, and you will avoid to re write functions in all your developments