O'Reilly logo

Beginning C++ Through Game Programming, Fourth Edition by Michael Dawson

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

CHAPTER 2TRUTH, BRANCHING, AND THE GAME LOOP: GUESS MY NUMBER

So far, the programs you’ve seen have been linear—each statement executes, in order, from top to bottom. However, to create interesting games, you need to write programs that execute (or skip) sections of code based on some condition. That’s the main topic of this chapter. Specifically, you’ll learn to:

images Understand truth (as C++ defines it)

images Use if statements to branch to sections of code

Use switch statements to select a section of code to execute

Use while and do loops to repeat sections ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required