Skip to main content
gamedev.net
🔒 Locked

pong physics

Started by Ultimate_Fusion 0 replies 600+ views
Original Post
Ultimate_Fusion
Ultimate_Fusion
I am making a classic pong game. I have managed to make the ball bounce off the paddle and and walls and come off at the opposite angle. I know i am meant to make the angle tighter if the ball hits the paddle, while the paddle it moving?? The ball goes the same speed all the time, is there away to increase the speed Proportionally to the speed of the paddle moving??
Bob Janova
Bob Janova
Well, sure there's a way, you just need to decide what you want.

Classic 'bounce' physics (what you have now) is a perfect elastic collision of the ball with a frictionless, infinite mass paddle (or wall), resulting in an impulse of -2v.n where v is the ball's velocity and n the normal of collision. (In Pong, n is always parallel to one of the axes, so the collision simply reverses the motion of one component of v.)

To have the paddle movement affect the ball, you need to invent some 'movement force'. This has no bearing in reality, so you can pick whatever you like :). (You could think of it as friction, i.e. the paddle pushes the ball in the direction it's moving, but in that case you would really impart spin to the ball as well which makes things a bit more tricky.) A simple suggestion would be to make the collision impulse -2v.n+kw, where w is the velocity of the 'wall' (or paddle) and k is a scalar constant that you fiddle with until the effect is as you want. (Again, w is probably axis-aligned so you will just affect one component of the ball's velocity – the opposite one to the bounce term.)

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.