Skip to main content
gamedev.net
🔒 Locked

adding physics....

Started by Darwinizer Aug 25, 2005 at 10:56 AM 2 replies 850+ views
Original Post
Darwinizer
Darwinizer
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
Spudder
Spudder
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.
JY
JY
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? :)
"Absorb what is useful, reject what is useless, and add what is specifically your own." - Lee Jun Fan

Topic Locked

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

Sign in to reply to this topic.