Archived

This topic is now archived and is closed to further replies.

Simple question about game states

This topic is 5777 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

My problem is that I used to have an application class that, on App.Run(), would simply create a window and initialize directX in the way that I wanted it, but now I''ve changed the function to something more like the following and its about 10 times slower.
  
void Application::Run()
{
	int NextState;

	while( State != QUIT )
	{
		switch( State )
		{
			case INIT:
			{
				NextState = Init();  // returns MAINMENU always

				break;
			}
			case MAINMENU:
			{
				NextState = MainMenu();  // can return QUIT or PLAY

				break;
			}
			case PLAY:
			{
				NextState = Play(); // can return MAINMENU or QUIT

				break;
			}
		}
		
		State = NextState;
	}
}

Can anyone help me with this?
~Vendayan  

Share this post


Link to post
Share on other sites
I might also add that the switch statement (which really isnt too bad) is obviously ran through only twice in the begining, once at the end and once every time you switch from the mainmenu and the game.

Share this post


Link to post
Share on other sites
Not sure if this is causing the slowdown. In fact, I don''t know why it would, but I''m curious - are you still satisfying the need for checking the message pump? Did your old Run() function have message pump code in the base class or somesuch?

Share this post


Link to post
Share on other sites