Program flow?

Started by
4 comments, last by bilsa 20 years, 4 months ago
Hia guys! Ok, I''m about to start a "real" 3d engine now... What I''m wondering is how I should manage my "flow" of the engine? This time I would like to do it in somewhat professional way. So far I have managed ok with something like this:

CBaseApplication {
virtual init();
virtual loop();
virtual extendedloop();
virtual draw();
virtual shutdown();
.
.
.
}
 
then when I wanted to make the init sceene or the in game flow or the menue in game, I just derived from this base. Then I used an object like: CBaseApplication *application; CGameMenue *mainMenue = new CGameMenue(); ... application = mainMenue; ... application->loop(); ... But I feel that this is somewhat newbee level of managing the program flow ? Now recently I have been thinking of somekind of StateManager, that keeps track of all available states... for eg. My mainMenue state or even the Init state of the whole application... ? This manager would keep track of all the in game "states" and what state they are in, eg. if the mainMenue stat is in the Init state or in the Loop state or whatever ? Does this sound like a better idea? How do u manage the "flow" in you applications? Please give me some nice ideas, I want it to look "elegant" and effective, but most of all so that it is dynamic and easy to add new states by just adding a new source file. (the latter gave me the idea of a global Singleton StateManager...) thx! c ya all!
Advertisement
Menue? is that really a word?
daerid@gmail.com
Take a look at the Enginuity series here on GameDev.

daerid: Menue is a word when you display the menue over your sceene
You don''t tell much what kind of game you are thinking about and how you will interact different features.

If you think of a modern 3dgame, then I a simple solution as this will be enough:

bool update( ... )
{
if( menu.enabled() )
menu.update(...);
else
game.update(...);
}

bool render(...)
{
game.render(...);
if( menu.enabled() )
menu.render(...);
}


In most games, I don''t really see why a statemanager should be needed. But you can of course make one. You can have a pointer to a CBaseapplicaiton inside your managerclass

CBaseApp* pMenu = new CMenu();
CBaseApp* pGame = new CGame();


main()
{
statemgr.setstate(MAINENGINE);
while(1)
{
statemgr.update();
}
}

Statemgr::setstate(int state)
{
m_state = state;
switch(state)
{
case MENU: m_subset = pMenu;
}
}

Statemgr::update()
{
if( m_action == INIT )
{
m_subset.init();
m_action = RUN;
}

if ( m_action == DEINIT )
{
m_subset.cleanup();
m_action = NULL;
}

if ( m_action == RUN )
{
m_subset.update();
m_subset.draw();
}

}

----------------------------------------------
Petter Nordlander

"There are only 10 kinds of people in the world. They who understand binary and those who do not"
----------------------------------------------Petter Nordlander"There are only 10 kinds of people in the world. They who understand binary and those who do not"
daerid ... just fuck off...

Well, actually I just wanted to hear from you guys how you have your applications built upp. I just wanted some ideas on how a good application should be built

And I want my application to "look" good, heh - where my idea about a statemanager came in. "the more complicated the better" hehe...

So feel free to post any method you use...

thx to the other two guys!
daerid ... just fuck off...

Well, actually I just wanted to hear from you guys how you have your applications built upp. I just wanted some ideas on how a good application should be built

And I want my application to "look" good, heh - where my idea about a statemanager came in. "the more complicated the better" hehe...

So feel free to post any method you use...

thx to the other two guys!

that eniginuity looks promising
(now that's exactly what I was looking for! hella great! thx !)

[edited by - bilsa on December 17, 2003 12:09:09 PM]

[edited by - bilsa on December 17, 2003 12:48:19 PM]

This topic is closed to new replies.

Advertisement