Salutations sir, I'v got a problem again..I guess this line of code is where the collision is detected right, of the ball and the wall, rite?

if(X[5]-X[2]<size2){// m2 & wall
if(coeff>0.){
ddt=dt-(X[2]+size2-X[5])/V[2];
if(ddt<dt){
X[2]-=(V[2]-v0)*ddt;
X[5]-=(V[5]-v0)*ddt;
//V[2]=-coeff*V[2];
V[2]=-V[2];
if(frame==3)v0=(m1*V[1]+m2*V[2])/mcm;
v0=V[frame];
X[2]-=(V[2]-v0)*ddt;
X[5]-=(V[5]-v0)*ddt;
}
}else if(V[1]==V[2]) V[1]=V[2]=0.;
else V[2]=0;
}
V[3]=(m1*V[1]+m2*V[2])/mcm;
v0=V[frame];
X[3]=((m1*X[1]+m2*X[2])/mcm);
drawIt();
}

But when i changed the distance of the two walls further apart...

[color=blue]original code[/color]

[color=limegreen]g[/color].fillRect((int)X[4]-size,yc-size4,size2,size8);
[color=limegreen]g[/color].fillRect((int)X[5]-size,yc-size4,size2,size8);

[color=red]to this[/color]

[color=limegreen]g[/color].fillRect(0,yc-size4,size2,size8);
[color=limegreen]g[/color].fillRect((int)X[5]+39,yc-size4,size2,size8);

..the balls [color=red]don't move rite to the wall and before even reaching the wall they bounce back[/color] as if bouncing off the walls however proceed with the normal collision  ???.

Can u help me sir in explaining how do the balls actually "know" when they hit the wall and how should I lengthen the ability of the balls to travel, similar to how the balls in your collision 2D are capable of  :-\. Thank you so much  :)