Loops


Most of what happens in computer programs happens repeatedly. For instance, I mentioned in chapter 1 that computeranimation happens one frame at a time. During each frame, the game performs a certain set of steps. Specifically, the game gets user input, updates the scene according to the input, draws the updated scene into the frame buffer, which is the back buffer we discussed in chapter 1. It then displays the contents of the frame buffer by swapping the front and back buffers. Figure 2.7 illustrates this process.

Figure 2.7. During each frame of animation, games perform these steps.


Programs perform repetitive tasks like the one shown in Figure 2.7 by using loops. There are several types of loops you can use. For now, I'll introduce the while and do-while loops.



Creating Games in C++(c) A Step-by-Step Guide
Creating Games in C++: A Step-by-Step Guide
ISBN: 0735714347
EAN: 2147483647
Year: N/A
Pages: 148

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net