C++ help

Discussion in 'Mac Programming' started by Ben Dixon, Feb 16, 2011.

  1. Ben Dixon macrumors member

    Sep 16, 2008
    Stafford, UK

    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

  2. balamw Moderator


    Staff Member

    Aug 16, 2005
    New England
  3. Ben Dixon thread starter macrumors member

    Sep 16, 2008
    Stafford, UK
    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:

    int WorldData::worldDataModuleInit()
    /* Initialise dynamics parameters for physics simulation */
    setPosition(500.0f, 20.0f);
    /* Initialise appearance parameters of game object */
    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()

Share This Page