Calculating degrees for bouncing ball
<p>I'm doing a simple breakout game and I have some problem how to calculate the angle when the ball hit the top border. When the ball moves upwards in an angle of 180 degrees, then it bouncing back downwards in an angle of 0 degrees. But when the ball is moving upwards in an angle of 170 degrees, then it should be bouncing back downwards in a mirrored angle, like 10 degrees. I can calculate this like <code>180-170 = 10</code> degrees, but what if the ball is moving upwards in an angle of 190 degrees!? Then it should be bouncing back downwards in an angle of 350 degrees, but I don't know how to calculate this!?</p>

<p>Is there a simple way to calculate or mirror the value of the upwards moving angle of the ball? Preciate some help because I'm not good in math! Thanks!</p>

<p>EDIT:
I'm moving the ball like this:</p>

<pre><code>xPos += speed * Math.sin(Math.toRadians(direction));
yPos += speed * Math.cos(Math.toRadians(direction));
</code></pre>
