Thread: Text RPG, how do I set up my program?

  1. #1
    Registered User
    Join Date
    Apr 2008
    Posts
    19

    Text RPG, how do I set up my program?

    I don't know if thats the right way to put it. I have it game set up the following way

    Code:
    int main(){
    game rungame;
    rungame.start();
    return 0;
    }
    All my classes have been declared and such. I have included the needed stuff for it any everything. My question is, where does the bulk of what happens in my game go? As it is now I have everything happening in my Game class.

    Code:
    class Game {
    public:
            void start();
    };
    void Game::Start() {
    // every single thing that happens is coded here
    }
    Is this the correct way to go about doing it?

  2. #2
    Registered User
    Join Date
    Oct 2006
    Location
    UK/Norway
    Posts
    485
    I would do it something like this:

    Code:
    int main()
    {
    	if(game.inisialize())  // Read needed data from file, create memory
    	{
    		while(game.isRunning())  // While the game has not ended, isRunning returns true
    		{
    			game.update();   // Move players and so
    		}
    
    		game.cleanUp();  // Clear used memory and stuff like that
    	}
    }
    And then in the update() function I would get user input, move players and calculate everything.

    But there are many ways to do this, mine is probably not the best

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. simple text analyzsis program
    By prominababy in forum C Programming
    Replies: 4
    Last Post: 04-16-2009, 10:15 AM
  2. accessing text from another program
    By Bozyo in forum Windows Programming
    Replies: 1
    Last Post: 08-05-2004, 12:17 PM
  3. Unknown Memory Leak in Init() Function
    By CodeHacker in forum Windows Programming
    Replies: 3
    Last Post: 07-09-2004, 09:54 AM
  4. fopen();
    By GanglyLamb in forum C Programming
    Replies: 8
    Last Post: 11-03-2002, 12:39 PM
  5. Program help
    By Trebor in forum C++ Programming
    Replies: 4
    Last Post: 06-04-2002, 03:19 PM