Quote Originally Posted by User137
Here's fix
http://pastebin.com/m640127ea

There was small typo in mass formula i think, and recursive for loop for collision is changed. Also replaced sqrt and power functions with built in hypot function for simplicity and speed.

...

After testing i noticed it still doesn't work well when gravity is applied with several more balls. That's when they start to move along edge of each other and slightly inside. Anyway i've never managed to make collision this realistic myself.
Yeah i compared the sources, its b1.mass + b1.masss :?
and the loop logic was broken

Thx :!: