Collision detection in Breakout

Started by
9 comments, last by Tran Minh Quang 21 years, 1 month ago
How you handle the actual collision of the ball depends on how you represent the balls velocity. If you have two separate variables for the vertical and horizontal speed components of the ball (i.e. deltaX and deltaY) then it’s quite easy, just invert the required variable.

For example if your ball is traveling right deltaX will most probably be a positive number, if it collides with something deltaX = deltaX * -1, your ball is now traveling left, when the ball collides with something again apply the same formula and your ball is traveling right again.

This topic is closed to new replies.

Advertisement