The main loop

Even during the early 1980s, when programmers wrote games in pure assembly language without the help of an engine such as Unity, the concept of Game Loops existed. During that time, the implementation of a Game Loop needed to be precise in its timing, because it had to synchronize correctly with the movement of a CRT's television electron gun, or the image on the screen would get distorted and the game would become unresponsive.

The following is an example of a game loop written in assembly for an Atari 2600. You can see the main routine calling a specific sequence of sub-routines cyclically. Each sub-routine runs at a particular phase of an analog television's screen drawing sequence. Between every step, you can do calculations, ...

Get Hands-On Game Development Patterns with Unity 2019 now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.