/Game-Loops

Creation of different game loops where a cube moves diagonally across the screen.

Primary LanguageC++

Game-Loops

Creation of different game loops where a cube moves diagonally across the screen. There are three different game loops with different ways to work.

  • Game Loop Examples: In this game loops, the cube travels accross the screen indefinitely, without taking into account the borders of the screen. And for each example, the game loops are CPU dependant (Example 1), FPS dependant (Example 2) and finally, it depends on the delta time variable (Example 3).
  • Game Loop Fixed: In this game loop, the cube travels accross the screen, but the position of the cube will get reset if it gets out of the screen. In addition, the variable delta time it will be constant.
  • Game Loop Variable: In this game loop, the cube travels accross the screen, but the position of the cube will get reset if it gets out of the screen. In addition, the variable delta time it will variate in each iteration.

In the last two game loops, when resetting the player's position, we have created a functionality that makes the player's direction change. This way you can see how the cube collides with the different walls.

Below we can see how one of the game loops works:

Records

Game Loop Variable Game Loop Variable