gardon
03-16-2006, 03:26 PM
I'm having a problem drawing to the screen based on gameStates. I'm not a noob, and this is a serious problem that I can't spend any more time slaving over.
The program runs like this:
while (menu->IsRunning()) // which returns true until the prog exits
{
Poll for input;
switch (g_globalState) // initially set to MENU above
{
case Menu:
g_globalState = Menu->Run() // which returns the global state
// after updating Menu
case GAMELOOP;
g_globalState = Engine->Run() // which does the same thing
}
}
-- end sample
So each frame it updates itself and checks for the globalState, which in turns either goes through Menu or Engine->Run(). once I Set the globalSTate to GAMELOOP through Menu options (I.e I click on the new game button) it goes to engine.
The problem I'm having is trying to get back to menu. I set the escape key to revert me back (setting globalSTate to MENU), which should run the MENU function and update it, however, it brings it back to menu but consistently draws and updates GAMELOOP as well.
It's like the switch statement doesn't matter, and it's still updating engine, which causes a double overlap of time and animation..,
I'm using double buffering, but that shouldn't make a difference.
Thanks,
Jason
And if you guys have visual studio and wanna check it out, go here: <a href="http://massive-war.com/Demo.rar">Here</a>
The program runs like this:
while (menu->IsRunning()) // which returns true until the prog exits
{
Poll for input;
switch (g_globalState) // initially set to MENU above
{
case Menu:
g_globalState = Menu->Run() // which returns the global state
// after updating Menu
case GAMELOOP;
g_globalState = Engine->Run() // which does the same thing
}
}
-- end sample
So each frame it updates itself and checks for the globalState, which in turns either goes through Menu or Engine->Run(). once I Set the globalSTate to GAMELOOP through Menu options (I.e I click on the new game button) it goes to engine.
The problem I'm having is trying to get back to menu. I set the escape key to revert me back (setting globalSTate to MENU), which should run the MENU function and update it, however, it brings it back to menu but consistently draws and updates GAMELOOP as well.
It's like the switch statement doesn't matter, and it's still updating engine, which causes a double overlap of time and animation..,
I'm using double buffering, but that shouldn't make a difference.
Thanks,
Jason
And if you guys have visual studio and wanna check it out, go here: <a href="http://massive-war.com/Demo.rar">Here</a>