Essentially trying to do this game (oneslime.net), using some code I found on tinters

bool slimev::calcCollisions(Slime& i, Ball& j) { double x,y,d2; x=y=d2=0; // displacement from i to j y = (j.y - i.y); x = (j.x - i.x); // distance squared d2 = x * x + y * y; // dividing by 0 is bad if (d2 == 0) return false; // if d^2 < (30)^2, the disks have collided if (d2 < (i.r*j.r)) { double kii, kji, kij, kjj; kii=kji=kij=kjj=0; kji = (x * i.dx + y * i.dy) / d2; // k of j due to i kii = (x * i.dy - y * i.dx) / d2; // k of i due to i kij = (x * j.dx + y * j.dy) / d2; // k of i due to j kjj = (x * j.dy - y * j.dx) / d2; // k of j due to j // set velocity of i i.dy = kij * y + kii * x; i.dx = kij * x - kii * y; // set velocity of j j.dy = kji * y + kjj * x; j.dx = kji * x - kjj * y; return true; } return false; }

The problem with this code is that the Slimes bounce back off the ball, unlike the oneslime.net example. I dont want the ball to transfer any of its velocity to the Slimes. How would I go about this?

Also, in the oneslime.net applet, the ball never loses momentum. If you start the game and not touch the keys, the ball would bounce forever. In my code, the ball just sticks to the Slime, because the slime has no velocity to transfer to the ball. Else where in the code I add some small amount of positive force to the Y velocitys of the Slimes and the ball, in an attempt to simulate gravity.

I hope this is clear to someone with the appropriate knowledge.

Danke,