Jump to content

  • Log In with Google      Sign In   
  • Create Account


#Actualwarnexus

Posted 16 July 2013 - 08:57 PM

 

Although I remember there was a site that has a term about main game loop. Is main loop and game loop and game main loop the same?

While there is no standard set-in-stone-definitions...

Main loop = The exterior-most loop that the game runs in.
Game loop = Technically, I guess this could be any loop within the game, but people using this probably mean the same as 'Main loop'.
Main game loop = Somewhat redundant
Game main loop = Silly

At least, that's my experience - I'm not in the game industry myself, just a hobbyist trying to go indie.

Notice that the terms "main game loop" and "game main loop" never appear in the article you linked to, except in the title.
The author was probably just typing "Understanding the game loop", then decided to change it to the more common "main loop", but accidentally wrote, "Understanding the game main loop". That's my theory.

It is possible to have more than one "main loop", but unusual. For example, you might have a "main loop" for your splash screen while the game is first starting up and still loading, before going into the super-duperly-for-real main loop.
It's also possible to have a 'main loop within a main loop', but that's unusual in games. For example, in desktop applications when you pop up a dialog box, you can no longer interact with any of the other windows, and one way that is implemented is to have the dialog box be it's own loop that you are stuck in until you close the dialog box.

So while there is no governing body that defines, under penalty of death, the real definitions of each term, "main loop" is the most common usage, from what I've encountered.

You could kinda think of it like this: (warning: pseudocode for illustration purposes only)
main() <- "Entrypoint"
{
   startup() <-- Game initialization

   while(gameIsStillRunning) <-- main loop
   {
      GameState &currentState = GetCurrentGameState()

      while(weHaveInput)
      {
         //Let the current gamestate manage the input
         currentState.handleInput(input)
      }

      //Update the game based on the amount of time that has passed,
      //or else based on a fixed timestep (which is what the article was promoting).
      currentState.update(timeThatHasElapsed)

      currentState.draw()
   }

   shutdown() <-- Game cleanup
}

Main loop is the same as game loop. Okay I understand. Thanks for the pseudo-code as an illustration. 


#1warnexus

Posted 16 July 2013 - 08:57 PM

 

Although I remember there was a site that has a term about main game loop. Is main loop and game loop and game main loop the same?

While there is no standard set-in-stone-definitions...

Main loop = The exterior-most loop that the game runs in.
Game loop = Technically, I guess this could be any loop within the game, but people using this probably mean the same as 'Main loop'.
Main game loop = Somewhat redundant
Game main loop = Silly

At least, that's my experience - I'm not in the game industry myself, just a hobbyist trying to go indie.

Notice that the terms "main game loop" and "game main loop" never appear in the article you linked to, except in the title.
The author was probably just typing "Understanding the game loop", then decided to change it to the more common "main loop", but accidentally wrote, "Understanding the game main loop". That's my theory.

It is possible to have more than one "main loop", but unusual. For example, you might have a "main loop" for your splash screen while the game is first starting up and still loading, before going into the super-duperly-for-real main loop.
It's also possible to have a 'main loop within a main loop', but that's unusual in games. For example, in desktop applications when you pop up a dialog box, you can no longer interact with any of the other windows, and one way that is implemented is to have the dialog box be it's own loop that you are stuck in until you close the dialog box.

So while there is no governing body that defines, under penalty of death, the real definitions of each term, "main loop" is the most common usage, from what I've encountered.

You could kinda think of it like this: (warning: pseudocode for illustration purposes only)
main() <- "Entrypoint"
{
   startup() <-- Game initialization

   while(gameIsStillRunning) <-- main loop
   {
      GameState &currentState = GetCurrentGameState()

      while(weHaveInput)
      {
         //Let the current gamestate manage the input
         currentState.handleInput(input)
      }

      //Update the game based on the amount of time that has passed,
      //or else based on a fixed timestep (which is what the article was promoting).
      currentState.update(timeThatHasElapsed)

      currentState.draw()
   }

   shutdown() <-- Game cleanup
}

So main loop is the same as game loop. Thanks for the pseudo-code as an illustration. 


PARTNERS