< 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 project—one that harnesses all of the major concepts presented throughout the book.
In addition to learning about Cþþ and game programming, you’ll also learn how to organize your work, break down problems into manageable chunks, and refine your code. You’ll be challenged at times, but never overwhelmed. Most of all, you’ll have fun while learning. In the process, you’ll create some cool computer games and gain insight into the craft of game programming.
Chapter 1: Types, Variables, and Standard I/O: Lost Fortune. You’ll be introduced to the fundamentals of Cþþ, the standard language of the game industry. You’ll 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. You’ll create more interesting games by writing programs that execute, skip, or repeat sections of code based on some condition. You’ll learn how to generate random numbers to add some unpredictability to your games. And you’ll learn about the Game Loop—a fundamental way to organize your games to keep the action going.
xx Introduction
Chapter 3: For Loops, Strings, and Arrays: Word Jumble. You’ll learn about sequences and work with strings—sequences of characters that are perfect for word games. You also learn about software objects—entities 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. You’ll be introduced to a powerful library—a toolbox that game programmers (and even non-game programmers) rely on to hold collections of things, such as items in a player’s inventory. You’ll also learn about techniques that can help you plan larger game programs.
Chapter 5: Functions: Mad Lib. You’ll learn to break up your game programs into smaller, more manageable chunks of code. You’ll accomplish this by dis- covering functions, the fundamental units of logic in your game programs.
Chapter 6: References: Tic-Tac-Toe. You’ll learn how to share information with different parts of your programs in an efficient and clear manner. You’ll also see a brief example of AI (artificial intelligence) and you’ll learn how to give a computer opponent a little bit of personality.
Chapter 7: Pointers: Tic-Tac-Toe 2.0. You’ll begin to discover some of the most low-level and powerful features of Cþþ, such as how to directly address and manipulate your computer’s memory.
Chapter 8: Classes: Critter Caretaker. You’ll learn how to create your own kinds of objects and define the ways they’ll interact with each other through object- oriented programming. In the process, you’ll create your very own critter to care for.
Chapter 9: Advanced Classes and Dynamic Memory: Game Lobby. You’ll expand on your direct connection with the computer and learn to acquire and free memory as your game programs require. You’ll also see the pitfalls of using this “dynamic” memory and how to avoid them.
Chapter 10: Inheritance and Polymorphism: Blackjack. You’ll learn how to define objects in terms of other objects. Then you’ll pull everything you’ve learned together into one big final game. You’ll 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