I was looking at the program flow of lesson 21 and was wondering if this was a good alteration.
if ((active && !GameSwitch(currentGameState)) || keys[VK_ESCAPE]) // Active? Was There A Quit Received?
{
done=TRUE; // ESC or DrawGLScene Signalled A Quit
}
else // Not Time To Quit, Update Screen
{
SwapBuffers(hDC); // Swap Buffers (Double Buffering)
}
int GameSwitch(currentGameState)
{
switch(currentGameState)
{
case GAMESTATE_MAINMENU:
{
UpdateMainMenu();
RenderMainMenu();
}break;
case GAMESTATE_GAME:
{
UpdateGame();
RenderGame();
}break;
case GAMESTATE_CREDITS:
{
UpdateCredits();
RenderCredits();
}break;
default:break;
}
return 0;
}
My other idea was to split the function gameswitch into gamerender and gameupdate. (Not 100% sure how I will get user input and use it in gameupdate yet...)
if ((active && !GameRender(currentGameState)) || keys[VK_ESCAPE]) // Active? Was There A Quit Received?
{
done=TRUE; // ESC or DrawGLScene Signalled A Quit
}
else // Not Time To Quit, Update Screen
{
SwapBuffers(hDC); // Swap Buffers (Double Buffering)
}
int GameRender(currentGameState)
{
switch(currentGameState)
{
case GAMESTATE_MAINMENU:
{
RenderMainMenu();
}break;
case GAMESTATE_GAME:
{
RenderGame();
}break;
case GAMESTATE_CREDITS:
{
RenderCredits();
}break;
default:break;
}
return 0;
}
int GameUpdate(currentGameState)
{
switch(currentGameState)
{
case GAMESTATE_MAINMENU:
{
RenderMainMenu(/*Keys pressed?*/);
}break;
case GAMESTATE_GAME:
{
RenderGame();
}break;
case GAMESTATE_CREDITS:
{
RenderCredits();
}break;
default:break;
}
return 0;
}
Any suggestions?
Edit: I was thinking about it and I only need the arrow keys and space and enter for the gameupdate function...