Jump to content
  • Advertisement
Sign in to follow this  
Programmer101

Bouncing of a Ping Pong Ball

This topic is 4050 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

How would I simulate the bouncing of a ping-pong ball on a table. I need to be able it incorporate lateral velocity as well, not just vertical. Just to simulate the bounce for a ping-pong game.

Share this post


Link to post
Share on other sites
Advertisement
I know PhysX does that but I would rather not use it. I am trying to use my own physics for the project I'm working on now. All I really need to know is the equation for a bouncing ball.

Share this post


Link to post
Share on other sites
Okay thanks. How do I simulate the speed of acceleration and falling of the ball? Would it be an exponential function of time or something?

Share this post


Link to post
Share on other sites
very basically,


void Update(float dt)
{
acceleration = vector(0, -10); // gravity
velocity += acceleration * dt;
position += velocity * dt;

if (position.y - radius < table.y)
{
position.y = table.y + radius;

if (velocity.y < 0.0f)
velocity.y = -velocity.y;
}
}

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!