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/c7cb9642c53Its 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.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
| 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(); } |