I'm working on a breakout like game in java for class. (The pong-like paddle and ball where you try to break little rectangles by hitting them with the ball)
I wanted to try some advanced collision detection, so that if a ball hit a rectangle, it would bounce off of it correctly, like if it was moving on a path and collided through for 10 pixels, the collision detection would use these 10 pixels for moving the ball as it bounces.
Example crappy drawing in paint
I am using vectors for the ball movement. I found http://www.gamasutra.com/features/20020118/vandenhuevel_02.htm this site that shows how to do it right with a moving ball hitting a stationary ball, but I need it with rectangles. My question is, how do I apply the techniques from this site, to a ball->rectangle collision?
I thought about treating the nearest side of the rectangle as a line an the vector as a line and calculating the intersection, but I would appreciate some other advice on this.
I wanted to try some advanced collision detection, so that if a ball hit a rectangle, it would bounce off of it correctly, like if it was moving on a path and collided through for 10 pixels, the collision detection would use these 10 pixels for moving the ball as it bounces.
Example crappy drawing in paint
I am using vectors for the ball movement. I found http://www.gamasutra.com/features/20020118/vandenhuevel_02.htm this site that shows how to do it right with a moving ball hitting a stationary ball, but I need it with rectangles. My question is, how do I apply the techniques from this site, to a ball->rectangle collision?
I thought about treating the nearest side of the rectangle as a line an the vector as a line and calculating the intersection, but I would appreciate some other advice on this.


