Ball physics

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ilikepython
    Recognized Expert Contributor
    • Feb 2007
    • 844

    #1

    Ball physics

    Hi,
    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.
  • JonLT
    New Member
    • Jul 2007
    • 41

    #2
    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.

    Comment

    Working...