Circle collision is very different from box collision, since the rotation doesn’t matter. To check if two circles are colliding, you simple measure the distance between them, and compare that to their radii.
Because ball physics are comparable to billiards bouncing off each other, the physics are the same.
Work out the distance between them, if this is less than the sum of their radii, you evidently have a collision.
Then you need to move them back to when they just touched (dist between = the sum of radii).
Then, using the velocities of the balls:
You draw a line between the centres of the two balls and convert their velocities into components parallel to and perpendicular to the line.
If their have different masses, you need to perform some calculations, but if they are equal in mass, simply exchange the parallel velocities and keep the perpendicular velocities the same.
Hey, do you like games? So do we — that’s what makes Kongregate the best source of free games online. We have thousands upon thousands of free online games, from both one-man indies and large studios, rated and filtered so you can play the best of the best. Read more »