471,089 Members | 1,560 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,089 software developers and data experts.

Ball physics

844 Expert 512MB
I made a pong game with pygame. It works pretty good but I want the ball to bounce realistically. Just like in real pong when it bounces off the right edge it goes to the right and when it bounces off the left edge it goes to the left. Right now, I just reverse the x speed of the ball (3 becomes -3). I need a way for the ball to bounce off the paddle depending on where it hit. I tried looking on Google but I couldn't find anything. Does anyone know how to implement physics like in real pong?

Thanks in advance.
Apr 24 '07 #1
1 2157
on collision, devide you velocity vector in to components one perpendicular to the collision surface and on parallel. If you dont want frinction or "bounciness", all you need to do is to negate the perpendicular component. If you want frinction and "bounciness" scale the perpendicular component with a bounceCoef and the parallel with a frictionCoef, but tou still need to negate the perpendicular component.
Jul 24 '07 #2

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

2 posts views Thread by Satish Chimakurthi | last post: by
5 posts views Thread by carl bloc | last post: by
2 posts views Thread by Joan Parera | last post: by
1 post views Thread by sake | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.