Nick
2005.12.17, 06:55 PM
What is the logic behind making a class that will act as my global physics handler? I want a class that will hold pointers to all the actual objects in my world, step them through the physics, check collisions between them all, and then update the positions. Luckily this is all for 2d which makes the physics easier, but how would the class be structured? Does anyone all ready do something like this?
My reason for this is that as I get further into my game, the objects are starting to pile up and I need an easy way to step them all and detect collisions. I'm also using multiple classes for my objects (some are liquid containers, some are skeletons, some are just random objects) so that complicates matters a little more. My main goal is to make things easier. My goal is for a system that allows the following:
PhysicsHandler *aHandler;
...
aHandler->SetGravity(-9.8);
...
//create object X here
...
aHandler->AddObject(x);
...
aHandler->StepObjects(timeElapsed);
The main trouble I'm having is storing pointers to actual objects without creating new objects, and figuring out how to step them all individually, then detect collisions, then do this over and over to double check all the changes, then set the final data.
Any advice, suggestions, code samples, or whatever is really appreciated.
My reason for this is that as I get further into my game, the objects are starting to pile up and I need an easy way to step them all and detect collisions. I'm also using multiple classes for my objects (some are liquid containers, some are skeletons, some are just random objects) so that complicates matters a little more. My main goal is to make things easier. My goal is for a system that allows the following:
PhysicsHandler *aHandler;
...
aHandler->SetGravity(-9.8);
...
//create object X here
...
aHandler->AddObject(x);
...
aHandler->StepObjects(timeElapsed);
The main trouble I'm having is storing pointers to actual objects without creating new objects, and figuring out how to step them all individually, then detect collisions, then do this over and over to double check all the changes, then set the final data.
Any advice, suggestions, code samples, or whatever is really appreciated.