< Previous | Contents | Next >

How This Book Is Organized

I start at the very beginning of Cþþ and game programming, assuming no experience in either. As the chapters progress, I cover more advanced topics, building on previous material.

In each chapter, I cover one or several related topics. I move through concepts one step at a time by writing bite-sized, game-related programs to demonstrate each idea. At the end of each chapter, I combine some of the most important concepts in a single game. The last chapter of the book ends with the most ambitious projectone that harnesses all of the major concepts presented throughout the book.

In addition to learning about Cþþ and game programming, youll also learn how to organize your work, break down problems into manageable chunks, and refine your code. Youll be challenged at times, but never overwhelmed. Most of all, youll have fun while learning. In the process, youll create some cool computer games and gain insight into the craft of game programming.

Chapter 1: Types, Variables, and Standard I/O: Lost Fortune. Youll be introduced to the fundamentals of Cþþ, the standard language of the game industry. Youll learn to display output in a console window, perform arithmetic computations, use variables, and get player input from the keyboard.

Chapter 2: Truth, Branching, and the Game Loop: Guess My Number. Youll create more interesting games by writing programs that execute, skip, or repeat sections of code based on some condition. Youll learn how to generate random numbers to add some unpredictability to your games. And youll learn about the Game Loopa fundamental way to organize your games to keep the action going.

xx Introduction


Chapter 3: For Loops, Strings, and Arrays: Word Jumble. Youll learn about sequences and work with stringssequences of characters that are perfect for word games. You also learn about software objectsentities that can be used to represent objects in your games, such as alien spacecrafts, healing potions, or even the player himself.

Chapter 4: The Standard Template Library: Hangman. Youll be introduced to a powerful librarya toolbox that game programmers (and even non-game programmers) rely on to hold collections of things, such as items in a players inventory. Youll also learn about techniques that can help you plan larger game programs.

Chapter 5: Functions: Mad Lib. Youll learn to break up your game programs into smaller, more manageable chunks of code. Youll accomplish this by dis- covering functions, the fundamental units of logic in your game programs.

Chapter 6: References: Tic-Tac-Toe. Youll learn how to share information with different parts of your programs in an efficient and clear manner. Youll also see a brief example of AI (articial intelligence) and youll learn how to give a computer opponent a little bit of personality.

Chapter 7: Pointers: Tic-Tac-Toe 2.0. Youll begin to discover some of the most low-level and powerful features of Cþþ, such as how to directly address and manipulate your computers memory.

Chapter 8: Classes: Critter Caretaker. Youll learn how to create your own kinds of objects and define the ways theyll interact with each other through object- oriented programming. In the process, youll create your very own critter to care for.

Chapter 9: Advanced Classes and Dynamic Memory: Game Lobby. Youll expand on your direct connection with the computer and learn to acquire and free memory as your game programs require. Youll also see the pitfalls of using this dynamicmemory and how to avoid them.

Chapter 10: Inheritance and Polymorphism: Blackjack. Youll learn how to define objects in terms of other objects. Then youll pull everything youve learned together into one big final game. Youll see how a sizeable project is designed and implemented by creating a version of the classic casino game of Blackjack (tacky green felt not included).

Introduction xxi