I am working on a 2d breakout game but I am having problem with the collision. Currently the game is working good with a normal box collision for the ball and the brick.
But for making the ball speed negative/positive I need collision for different sides.
Image: http://i.imgur.com/KSKDN.gif
In the above image when the collisions for the left/right then ballSpeedX will be become "-ballSpeedX" and if its from top/bottm the speedY will be become -speedy.
I can't get this working. I used this for the bottom collision but it makes the ball appear under the brick even if its hit from left/right/top:
if(ball->y <= brick->bottom && ball->y >= brick->top)
ball->Setxy(ball->x, brick->bottom+1);
Can anyone help?
Thanks