Problem with Brick Breaker brick collision.

Hi guys,

I am currently developing a Brick Breaker game, but somehow I am not able to create a good collision response.

The collision detection works perfectly, but the response is a bit weird.

I tried many different ways this is my current try:

 http://pastebin.java-gaming.org/c7cb9642c53

Its mostly the way I want it to be, but sometimes the ball just turns in the wrong direction(The ball should Change X velocity but he is changing X and Y velocity).

I fixed it.

if(b.GetRight() - GetLeft() < 10) {
					
	b.ChangeX();
}
				
if(b.GetLeft() - GetRight() > -10) {
					
	b.ChangeX();
}
				
if(b.GetTop() - GetBot() < 10) {

	b.ChangeY();
}
				
if(b.GetBot() - GetTop() > -10) {
					
	b.ChangeY();
}