Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Ben Dixon

macrumors member
Original poster
Sep 16, 2008
74
1
Stafford, UK
Hey!

I'm wondering if I can get some help with a C++ problem I'm having at the moment.

This is for a physics engine and I am trying to refactor one class into two.

To begin with, I have a class called worldData.cpp and a second one called particleModel.h

I have an initialisation method in both .cpp files and want to call the particleModel initialisation inside the worldData class.

It's not just the initialisation though as I need to do this for other methods.

Any help is greatly appreciated

Ben
 
Hard to help without code.

You may want to read http://www.mikeash.com/getting_answers.html and ask again.

B

Sorry about that. It was getting late and I was stressing out quite a bit about it.

I'll try and explain it a little better.

First up is the worldData.cpp file. This, at the moment is responsible for loading in particles and such. I need to refactor the code so it has a separate class for the particles which I have named particleModel.cpp

One of the methods I have looks like this:

Code:
int WorldData::worldDataModuleInit()
{

/* Initialise dynamics parameters for physics simulation */
setPosition(500.0f, 20.0f);

/* Initialise appearance parameters of game object */
setShape2Square();

return 1;

}


I also have the same code in the particleModel.cpp class to initialise the particles and their position.

My question is, can I remove the setPosition() and setShape2Square() from the worldData.cpp class and call them from the particleModel.cpp class?

I have separate methods within the particleModel.cpp for setPosition() and setShape2Square()
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.