Jump to content

  • Log In with Google      Sign In   
  • Create Account


Is the main game same thing as the game loop?


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
8 replies to this topic

#1 warnexus   Prime Members   -  Reputation: 1402

Like
0Likes
Like

Posted 16 July 2013 - 01:10 PM

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/


Edited by warnexus, 16 July 2013 - 08:04 PM.


Sponsor:

#2 Waterlimon   Crossbones+   -  Reputation: 2483

Like
0Likes
Like

Posted 16 July 2013 - 01:19 PM

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


#3 MarekKnows.com   Members   -  Reputation: 479

Like
0Likes
Like

Posted 16 July 2013 - 05:20 PM

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.


---
Free C++, OpenGL, and Game Development Video Tutorials @
www.MarekKnows.com
Play my free games: Ghost Toast, Zing, Jewel Thief


#4 L. Spiro   Crossbones+   -  Reputation: 13318

Like
0Likes
Like

Posted 16 July 2013 - 06:18 PM

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


It is amazing how often people try to be unique, and yet they are always trying to make others be like them. - L. Spiro 2011
I spent most of my life learning the courage it takes to go out and get what I want. Now that I have it, I am not sure exactly what it is that I want. - L. Spiro 2013
I went to my local Subway once to find some guy yelling at the staff. When someone finally came to take my order and asked, “May I help you?”, I replied, “Yeah, I’ll have one asshole to go.”
L. Spiro Engine: http://lspiroengine.com
L. Spiro Engine Forums: http://lspiroengine.com/forums

#5 Servant of the Lord   Crossbones+   -  Reputation: 18584

Like
0Likes
Like

Posted 16 July 2013 - 06:31 PM

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.


Edited by Servant of the Lord, 16 July 2013 - 06:33 PM.

It's perfectly fine to abbreviate my username to 'Servant' rather than copy+pasting it all the time.
All glory be to the Man at the right hand... On David's throne the King will reign, and the Government will rest upon His shoulders. All the earth will see the salvation of God.
Of Stranger Flames - [indie turn-based rpg set in a para-historical French colony] | Indie RPG development journal

[Fly with me on Twitter] [Google+] [My broken website]

[Need web hosting? I personally like A Small Orange]


#6 warnexus   Prime Members   -  Reputation: 1402

Like
0Likes
Like

Posted 16 July 2013 - 08:00 PM

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/


Edited by warnexus, 16 July 2013 - 08:04 PM.


#7 Servant of the Lord   Crossbones+   -  Reputation: 18584

Like
0Likes
Like

Posted 16 July 2013 - 08:43 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
}

It's perfectly fine to abbreviate my username to 'Servant' rather than copy+pasting it all the time.
All glory be to the Man at the right hand... On David's throne the King will reign, and the Government will rest upon His shoulders. All the earth will see the salvation of God.
Of Stranger Flames - [indie turn-based rpg set in a para-historical French colony] | Indie RPG development journal

[Fly with me on Twitter] [Google+] [My broken website]

[Need web hosting? I personally like A Small Orange]


#8 warnexus   Prime Members   -  Reputation: 1402

Like
0Likes
Like

Posted 16 July 2013 - 08:47 PM

 

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!



#9 warnexus   Prime Members   -  Reputation: 1402

Like
0Likes
Like

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. 


Edited by warnexus, 16 July 2013 - 08:57 PM.





Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS