I have simple mechanism for testing of two balls colliding:
private static boolean isColliding(float firstBallX, float firstBallY, double firstBallRadius, float secondBallX, float secondBallY, double secondBallRadius) {
final double a = firstBallRadius + secondBallRadius;
final double dx = firstBallX - secondBallX;
final double dy = firstBallY - secondBallY;
return a * a > (dx * dx + dy * dy);
}
And it works great. One of the balls is moving and the other (second one) is static. I have two questions.
When a collision occurs, how do I change the movement of the first ball (the moving) one to its logical path? I suppose I should change the direction somehow, but cannot figure out how...?
The other question is how do I tell the static ball, after the collision move? And what is its path, direction and staff...?
Thanks in advance.