Jump to content
  • Advertisement
Sign in to follow this  
Darwinizer

adding physics....

This topic is 4835 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

Hey All- I'm trying to work out some design issues before I make a new try at a pong clone. (which I've discovered in my previous attempts to be much more difficult than a beginner would think). I would like to add some realistic physics so I'm working on a physics engine. My question is this. How would I best utilize the engine with the pong ball? Simply add a pointer to it in the ball class? I considered trying inheritence from it but that doesnt seem quite right. Thanks for your assitance. -Darwinizer

Share this post


Link to post
Share on other sites
Advertisement
A physics engine is a bit of an overkill for a simple pong game but what you can do is create a CPhysicsObject class (or whatever you decide to name it) which represents a single physical entity which can be simulated. This object will have properties like mass, velocity etc and an Simulate()/Update() function which you pass in an elapsed amount of time to use for physical simulation, this will typically be the elapsed amount of time between frames.

Then for you pong game you derive your ball object from CPhyicsObject and add in all the extra non-physical portions you need like rendering.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
A pong ball does not follow the law of gravity for example, so yes physics as such are probably overkill. However, getting realistic collision responses is the greater problem and is what you will have to deal with.

Share this post


Link to post
Share on other sites
But it might be nice if we moved on from the last 30 years and had a pong ball that _did_ obey the laws of gravity? :)

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!