Chapter 21: Loops

Computer programs are usually designed to do the same thing repeatedly. In a standard game loop, the game draws a frame to the screen, takes input from the player, considers that input, and then draws the next frame, repeating this behavior at least 30 times every second.

A loop in C# code causes the computer to repeat a certain behavior several times. This could be anything from looping over every enemy in the scene and considering the AI of each to looping over all the physics objects in a scene and checking for collisions. By the end of this chapter, you’ll understand all you need to know about loops, and in the next chapter, you’ll learn how to use them with Lists and arrays.

Errata

Lecture Notes

Tutorial Files