Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

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.

share|improve this question

1 Answer 1

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.