[quote author=Fu-Kwun Hwang link=topic=4.msg1553#msg1553 date=1185629988]
You are checking collision between n particles
with loop like
for(int i=0;i<n;i++){
for(j=0;j<n;j++){
}
}
In the above case, collision between particles might be processed twice.
You can change the loop to
for(int i=0;i<n;i++){
for(j=0;j<i;j++){
  if(i!=j){// particle can not collide with itself
  }
}

And I did not fully understand what do you mean by
"somethimes the balls don't colide right  Huh"!
You only tell me you think there is something wrong, But I did not know what is wrong!


}

[/quote]

the problem is that in 10% of colisions the backtime to make (distance = r1 + r2) does not work right and the ball keep inside the other one