[quote author=Fu-Kwun Hwang link=topic=41.msg7685#msg7685 date=1293105914]
The code to process collision will fail if you have two balls at the same position. (This would not happened in real life).

If you have more than two ball , i.e. n ball
You need a double loop to process possible collision between any two balls.
The original code only process collision between two ball.
Change it a function e.g. collision(i,j) which will process collision between particle i and j.
The double will look like
for(int i=0;i<n;i++){
for(int j=i+1;j<n;j++){

You are welcomed to check out [url=http://www.phy.ntnu.edu.tw/ntnujava/index.php?topic=120.0]Collision 2D[/url] to find more information.

Am totally lost. There is already something similar to that in the code. Are you saying I need to do that again or not?

Honestly can't get it done....