Jump to content
  • Advertisement

Archived

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

Vendayan

Simple question about game states

This topic is 5992 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
Advertisement
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
Yes my old run function had the message pump, but now mianmenu() and play() both have their own message pumps. Init() doesnt need one because its too quick.

~Vendayan

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!