Bouncing of a Ping Pong Ball
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.
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.
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?
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; }}
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement