Hi, im making a game, and it has a rendering loop that looks something like this:
renderingLoop()
{
if (isCompanyLogo)
{
drawCompanyLogoSplashScreen()
if (enterKeyPressed)
{
isMainTitleScreen = true
isCompanyLogo = false
}
}
else if (isMainTitleScreen)
{
drawMainTitleScreen()
if (enterKeyPressed)
{
isGameStarted = true
isMainTitleScreen = false
}
}
else if (isGameStarted)
{
drawMainGame()
}
}
The game first shows the company slash screen, then when the user hits 'ENTER' it should go to the main title screen, then when they hit 'ENTER' again it should go to the game.
My problem is that when in the splash screen area, when they hit enter, the rendering loop is so fast that it skips all the way to the main game. The rendering loop runs at 60 fps, when the user presses enter, by the time they let go of enter the loop has run many many times, and thus it skips to the main game because isEnterKeyPressed is true for so long.
I'm trying to think of a good way to be able to add delays between events in the game, and being allowed to press a button. Does anyone know any really good solutions or the most common practice for adding delays to the game interactivity and ingame events? Thread.Sleep() is not an option because the rendering loop should never stop until the game is closed.
It would be good if it could be used not only for adding a 5 second delay between skipping title screens, etc, but also if I could use it to add delay between events happening within the game.
What I am looking for is a way that I can type something like:
addDelay(10);
Into the render loop, which would then wait 10 seconds before continuing.
Any help or suggestions is appreciated!
Message was edited by:
EvolvedAnt