Rich Porter
Rich Porter

Reputation: 213

How do physics work for ball and paddle style games like Breakout and Pong?

I have the following game:

enter image description here

I have the rectangle collisions ready with the ball and with the tiles. but my problem is when the ball hits the tiles and the bat, what angle should the ball bounce at? How do I determine that?

Upvotes: 0

Views: 2998

Answers (3)

Steve H
Steve H

Reputation: 5519

There is actually a built in method in the XNA Vector2 class just for this. Check out the Vector2.Reflect method.

Upvotes: 0

BlackBear
BlackBear

Reputation: 22979

It's not that difficult, if the ball hits a vertical obstacle simply invert its x velocity, if it hits a horizontal obstacle invert its y velocity.

Upvotes: 2

George Stocker
George Stocker

Reputation: 57877

You should read up on physics, specifically Reflection. There are lots of tutorials on Breakout style physics.

Upvotes: 4

Related Questions