The Loop

Launching the program instantiates the Game class. As of now, the main function makes a single call to the Game constructor.

The game constructor contains the control flow for the game loop, so it's where the Game remains for as long as it's running. The game consists of four major functions: initialize, loadContent, update, and draw.

These four functions are the backbone of the game loop. Any class that updates has an update method, and every class that draws has a draw method. When tasks are relegated to manager classes, they can be hooked into the game loop simply by making the appropriate calls in these methods. For example, the following diagram shows the cascade of update and draw calls that draws a sprite to the screen.