I'm using a standard square collision in my 2D game. The player shoots little balls, and when they hit any wall it should bounce.
The problem is that I know when it hits a wall but I don't know if the collision happened on the side or top/bottom of the wall.
Here's my collision algorithm (pseudo code):
If A.x < (B.x + B.width) AND B.x < (A.x + A.width) AND A.y < (B.y + B.height) AND B.y < (A.y + A.height) Then a collision happened
Is it easy to detect if the collision happened on a side or top/bottom? If yes how should I do it?