Game Loop - SC-SGS/surviving-sarntal GitHub Wiki
#Game Loop
The game loop is the central control unit of our program and defines the interaction of the game's core components. It contains all the logic and data needed to run the actual gameplay. Our game loop is depicted below. For the most part, it adheres to the industry standard as described by Nystrom and the Unity framework. Hence, we will only briefly describe its functionality here.
At the start of the game loop, input from the player, be it via keyboard or gamepad, is registered and passed to the physics engine. The physics engine progresses the simulation in one or more constant time steps between frames, thereby processing the collected input events. Finally, the renderer draws the new frame representing the updated world state.
Due to the sequential nature of input receipt, input processing, simulating a physics step, and rendering the resulting new state of the world, the game loop is also inherently sequential. For very large games or powerful frameworks such as the aforementioned Unity framework, a parallelization becomes inevitable, but in our game, this structure suffices. The physics engine does not have to run on a separate thread for our purpose. Merely the terrain generation is extracted from the spawning phase of the physics engine in order to guarantee a smooth transition between biomes during gameplay.