I feel like I'm going to make this highly convoluted so please bear with me. I'm in the process of teaching myself C++ and SFML(2.0) and am making a relatively simple game. I have multiple rocks bouncing around the screen that I want to bounce off of each other.
Right now I have them bouncing off the edges of the screen fine, and off each other when colliding along the x axis. This is really an issue of math I think (and my main problem is my math skills are very lacking). I have, in the collision detection code, the rock's angle changing using the formula: angle = Pi - angle (which works when bouncing off the left and right sides of the screen). However, my code for bouncing off the top and bottom of the screen simply inverts the angle (angle = -angle).
I know using "angle = -angle" will work for y axis rock-to-rock collisions, so I guess my question is, how do I check (once they have collided) whether to use "angle = -angle" or "angle = Pi - angle"?