Is the main game same thing as the game loop?

Started by
7 comments, last by Nicholas Kong 10 years, 9 months ago

I need someone to clear up the confusion I am having about this.

The source of my confusion is from this:

http://higherorderfun.com/blog/2010/08/17/understanding-the-game-main-loop/

Advertisement
Im not sure what you mean (clarify?) but the game loop is what calls the frame by frame update methods of your games systems (physics.update(), renderer.render(), input.process()...)

i think.


There could be multiple such high level loops or states that affect what the loop does (splash screen, main menu, editor)

o3o

main is where you will find the start of your game. This is where the program starts. Inside main, you would typically have your game loop where all your logic, physics, rendering etc will happen. Main could also spawn other threads so that you can process things in parallel if you need better performance.

A game loop is a loop that repeatedly updates the core processes of your game—a cycle that repeats in order to continuously cause game logic and rendering to take place and to receive input and network events, etc.

The “main game” is a higher-level concept describing the main area of the game. In a fighting game this would be the actual fighting part of the game. In a top-down shooter this would be the area where you fly and shoot. This contrasts with other parts of the game such as the main menu, credits screen, etc.

“Main game” is rarely or never used because it is very abstract and could refer to almost anything between different people, which is exactly why you are confused right now.

In general, never use the term “main game”.

L. Spiro

I restore Nintendo 64 video-game OST’s into HD! https://www.youtube.com/channel/UCCtX_wedtZ5BoyQBXEhnVZw/playlists?view=1&sort=lad&flow=grid

Is the main game same thing as the game loop?

No, the main menu, the gameplay itself (which can be broken into various forms even in a single game), the in-game menu, and everything else are all inside the game loop. The game loop contains everything show to the player visually, and everything done logically, aside from the very initial initialization and the very end freeing of resources.

It various from game to game, what is done before and after the main loop, but the main menu should occur inside the game loop. The main menu just a different "game state" within the loop. 'Combat' may be a different game state, 'Exploring' may be a different state, same with 'Shopping', 'NPC Dialog', 'Loading screen', 'main menu', 'in-game microtransaction store', and more.

Even though you might be using a different API, or perhaps even an entirely different language, this article explains game loops decently well, and this article explains game states, and it applies to most APIs and most languages - though some APIs hide the game loop from you, depending on how high-level they are.

A game loop is a loop that repeatedly updates the core processes of your game—a cycle that repeats in order to continuously cause game logic and rendering to take place and to receive input and network events, etc.

The “main game” is a higher-level concept describing the main area of the game. In a fighting game this would be the actual fighting part of the game. In a top-down shooter this would be the area where you fly and shoot. This contrasts with other parts of the game such as the main menu, credits screen, etc.

“Main game” is rarely or never used because it is very abstract and could refer to almost anything between different people, which is exactly why you are confused right now.

In general, never use the term “main game”.

L. Spiro

Hey L. Spiro!

I see. Okay I will not use the term again. I agree it is very vague and abstract.

Thanks for the knowledge on game loop!

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?

The source of my confusion is from this:

http://higherorderfun.com/blog/2010/08/17/understanding-the-game-main-loop/

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
}

Is the main game same thing as the game loop?

No, the main menu, the gameplay itself (which can be broken into various forms even in a single game), the in-game menu, and everything else are all inside the game loop. The game loop contains everything show to the player visually, and everything done logically, aside from the very initial initialization and the very end freeing of resources.

It various from game to game, what is done before and after the main loop, but the main menu should occur inside the game loop. The main menu just a different "game state" within the loop. 'Combat' may be a different game state, 'Exploring' may be a different state, same with 'Shopping', 'NPC Dialog', 'Loading screen', 'main menu', 'in-game microtransaction store', and more.

Even though you might be using a different API, or perhaps even an entirely different language, this article explains game loops decently well, and this article explains game states, and it applies to most APIs and most languages - though some APIs hide the game loop from you, depending on how high-level they are.

Thanks for the articles!

That reminds me I need to put the main menu in the game loop so I can actually go revisit the main menu for the game!

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.

This topic is closed to new replies.

Advertisement