Preface

Today, video games are some of the most popular forms of entertainment. Newzoo’s “Global Games Market Report” estimates over $100 billion in revenue for games in 2017. This staggering amount shows how popular this field truly is. Because of the size of this market, game programmers are in low supply and high demand.

Alongside this explosion of games, game technology has become increasingly democratized. A single developer can make award-winning and hit games by using one of many popular game engines and tools. For game designers, these tools are fantastic. So what value is there in learning how to program games in C++?

If you take a step back, you can see that many game engines and tools are, at their core, written in C++. This means that C++ is ultimately the technology behind every game created using one of these tools.

Furthermore, top-notch developers who release some of the most popular games today—including Overwatch, Call of Duty, and Uncharted—still predominantly use C++ because it provides a great combination of performance and usability. Thus, any developer who wants to eventually work for one of these companies needs a strong understanding of programming games—specifically in C++.

This book dives into many of the technologies and systems that real game developers use. The basis for much of the material in this book is video game programming courses taught at the University of Southern California over the course of almost a decade. The approach used in this book has successfully prepared many students to make it in the video games industry.

This book is also heavily focused on real working implementations of code integrated into actual game project demos. It is critical to understand how all the various systems that go into a game work together. For this reason, you should keep the source code handy while working through this book.

At this writing, all the code provided with this book works on both PC and macOS, using the Microsoft Visual Studio 2017 and Apple Xcode 9 development environments, respectively.

The source code for this book is available on GitHub, at https://github.com/gameprogcpp/code. For instructions on setting up the development environment for this book, see Chapter 1, “Game Programming Overview.”

Who Should Read This Book?

This book is for you if you’re a programmer who is comfortable with C++ and wants to learn how to program 3D video games. For readers rusty on C++, Appendix A, “Intermediate C++ Review,” reviews several C++ concepts. However, if you have with little or no prior C++ experience, you should learn C++ before jumping into this book. (One option is Programming Abstractions in C++ by Eric Roberts.) This book also expects you to be familiar with some common data structures, including dynamic arrays (vectors), trees, and graphs, and to have some recollection of high school-level algebra.

The topics covered in this book are applicable to readers in academic environments, hobbyists, and junior- and mid-level game programmers who want to expand their knowledge of game programming. The content in this book corresponds to a little more than a semester and a half of material in a university setting.

How This Book Is Organized

This book is intended to be read linearly from Chapter 1 through Chapter 14. However, in case you are not interested in some specific topics, Figure P.1 shows the dependencies between the chapters.

In the first handful of chapters, the games are in 2D as you learn core concepts. From Chapter 6 onward (with the exception of Chapter 8), the games are in 3D.

The chapters cover the following information:

  • Chapter 1, “Game Programming Overview,” looks at the fundamental concepts of game programming and how to get an initial game up and running. It also introduces the Simple DirectMedia Layer (SDL) library.

  • Chapter 2, “Game Objects and 2D Graphics,” discusses how programmers organize the objects in their games and explores additional 2D graphics concepts, such as flipbook animation.

  • Chapter 3, “Vectors and Basic Physics,” covers mathematical vectors, which are critical tools for any game programmer. It also explores the basics of physics, for use with both motion and collisions.

  • Chapter 4, “Artificial Intelligence,” looks at approaches to make game characters that are computer controlled, including concepts such as state machines and pathfinding.

  • Chapter 5, “OpenGL,” explores how to create an OpenGL renderer, including implementing vertex and pixel shaders. It includes a discussion of matrices.

Image

Figure P.1 Chapter dependencies

  • Chapter 6, “3D Graphics,” focuses on converting the code created so far to work for a 3D game, including how to represent the view, projection, and rotations.

  • Chapter 7, “Audio,” covers how to bootstrap an audio system using the excellent FMOD API. It includes coverage of 3D positional audio.

  • Chapter 8, “Input Systems,” discusses how to design a more robust input system for processing keyboard, mouse, and game controller events.

  • Chapter 9, “Cameras,” shows how to implement several different 3D cameras, including a first-person camera, a follow camera, and an orbit camera.

  • Chapter 10, “Collision Detection,” dives into methods of collision detection for games, including spheres, planes, line segments, and boxes.

  • Chapter 11, “User Interfaces,” looks at implementing both a menu system and heads-up display (HUD) elements such as a radar and aiming reticule.

  • Chapter 12, “Skeletal Animation,” covers how to animate characters in 3D.

  • Chapter 13, “Intermediate Graphics,” explores a handful of intermediate graphics topics, including how to implement deferred shading.

  • Chapter 14, “Level Files and Binary Data,” discusses how to load and save level files, as well as how to write binary file formats.

  • Appendix A, “Intermediate C++ Review,” reviews several intermediate C++ topics used throughout the book including memory allocation and collections.

Each chapter includes a corresponding game project (with source code available, as mentioned), recommended additional readings, and a couple of exercises. These exercises generally instruct you to add additional features to the code implemented in the chapter.

Conventions Used in This Book

New terms appear in bold. Code appears in a monospaced font. Small snippets of code sometimes appear as standalone paragraphs:

DoSomething();

Longer code segments appear in code listings, as in Listing P.1.

Listing P.1 Sample Code Listing


void DoSomething()
{
   // Do the thing
   ThisDoesSomething();
}


From time to time, some paragraphs appear as notes, tips, sidebars, and warnings. Here is an example of each.

note

Notes contain some useful information about implementation changes or other features that are worth noting.

tip

Tips provide hints on how to add certain additional features to your code.

warning

Warnings call out specific pitfalls that warrant caution.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.144.17.237