Game and Ball Hit problem
807601Dec 8 2007 — edited Dec 8 2007Hello everyone, I am working on a game and was wondering if I could get some help. I have a ball that bounces around in a box, and place one small ball in the applet. I want to create an effect that when the ball that is moving comes into connect with the static ball, the moving ball bounces in the opposite direction. I used this:
if(x_pos - 100 < 2 & y_pos - 100 < 2 || 100-x_pos < 2 && 100 - y_pos < 2)
where x_pos and y_pos are for the moving ball, and 100 is the radius of the static ball. Should I use the Pythagoras theorem to do it?
Thank You In Advance for any help.