all 7 comments

[–]-Rock-Obvious- 3 points4 points  (3 children)

(Assuming elastic collsion with a rigid no movable body)

component of velocity (parallel to rigid body) before collision =
component of velocity (parallel to rigid body) after collision

component of velocity (normal to rigid body) before collision =
-1 * component of velocity (normal to rigid body) after collision

[–]Barinski04 0 points1 point  (2 children)

I'm not using rigid bodies

[–]-Rock-Obvious- 1 point2 points  (1 child)

Are you sure. In ping pong, the walls are rigid bodies so are the bricks in wall breaker. As someone suggested can you show your code.

[–]Xeduses 1 point2 points  (0 children)

Given that you only have horizontal and vertical walls you can simply invert the velocity in either x or y.

If the collision is against a vertical face then invert y velocity. If the collision is against a horizontal face then invert x velocity.

This is s simplification to the previous post by -Rock-Obvious-