4
\$\begingroup\$

What is the relationship between FPS - Frames Per Second and a game loop? I'm confused how my book is using theses terms.

\$\endgroup\$
9
\$\begingroup\$

Typically, a frame is drawn every time through the game loop. Thus, the FPS tells you how fast the game is looping.

That said, more sophisticated rendering architectures often decouple the rendering from the main game loop. In that case, the two are only vaguely related.

| improve this answer | |
\$\endgroup\$
2
\$\begingroup\$

FPS is usually graphics-related in such way, that it is a measure of video rendering time - how many (video) frames per second is game producing, while Game Loop (or Tick) is related to game-states calculations like: physics, reading and applying of user inputs, udates of game entities, handling network i/o etc.

The reason why it is often mixed is that many game engines are using the same single loop calculate its state and then video render.

Note that very often video rendering and/or game loop is synchronised with display refresh rate (VSync) to avoid flickering of screen.

| improve this answer | |
\$\endgroup\$
0
\$\begingroup\$

First of all, games usually execute 60 FPS on a good computer. To explain the relationship between FPS and the game loop, we have to delve deeper. We have to ask ourselves another question, "How can the FPS and the game loop affect each other?"

The FPS is the frames per second, as you know. The game loop is how the game functions when it executes.

while(isRunning){
    updateGameStatus();
    renderScreen();
}

In this example I've written using Java, the FPS is not mentioned. Because of this, the FPS has no influence on how fast the game runs. But think about this; Don't we want the FPS to influence the game? The answer is of course yes. When the computer updates the game, it's going to update as fast as it possibly can, but sometimes it cannot render as fast as it can. This can lead to extreme lag issues.

 int myFPS = 60;

 while(isRunning){

      if(this.getFPS() < myFPS){
           //We are running behind!
      }

      if(this.getFPS() > myFPS){
           update();
           render();
      }

 }

In this example ( in Java ) , I show what a more sophisticated game loop would look like, where the FPS actually DICTATES when the computer will run. Often times, programmers will incorporate a "tick skipping sequence", which will basically ignore all the lost ticks.

So to answer your question, the FPS can have influence on your game loop. It just requires some additional knowledge and code.

| improve this answer | |
\$\endgroup\$
  • \$\begingroup\$ I think these examples and exaggerated attitude are both misleading. \$\endgroup\$ – madneon Nov 10 '15 at 3:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.