This is the code repository for Practical C++ Game Programming with Data Structures and Algorithms, First Edition, published by Packt.
Zhenyu George Li, Charles Shih-I Yeh
Game development demands performance-driven solutions—from rendering complex 3D scenes to managing AI behavior and handling animations. This hands-on book guides you in solving these challenges using high-performance C++ data structures and algorithms. The authors distill their decades of combined industry experience to help you apply practical C++ techniques to create smooth, scalable, and intelligent games. Instead of pseudocode or abstract theory, you’ll work with real, executable examples that translate directly to your projects. Demos in this book have been developed based on raylib library, providing accessible and efficient foundations for learning. Opening with a structured overview of algorithmic thinking in C++ game development, the book covers advanced algorithms and their applications in real-world game scenarios. You’ll implement data structures that optimize game functionality, solve algorithmic problems efficiently, and enhance gameplay with robust AI and rendering techniques. In addition, the key focus is collision detection, 2D/3D rendering, animation, camera controls, and machine learning-driven AI, all through practical, executable C++ code. By the end of this book, you’ll be able to confidently apply advanced C++ techniques to develop efficient, scalable, and feature-rich gameplay systems for modern games.
- Apply data structures and algorithms to solve real game development problems
- Apply rendering techniques, such as shader, lighting, soft shadow, particles, and quad-tree terrain
- Build dynamic camera systems like third-person, rail, top-down, and split-screen views
- Animate skeletal characters using interpolation and inverse kinematics
- Implement NPC AI with FSM, behavior tree, A* pathfinding, and steering
- Explore ML with neural networks in a hands-on AI turret defense project
- Performance and memory optimization using techniques like object pooling and LOD
- Gearing Up: C++ for Game Development
- Data Structures in Action: Building Game Functionality
- Algorithms Commonly Utilized in Game Development
- 2D Rendering and Effects
- The Camera and Camera Controls
- 3D Graphics Rendering
- Rendering a 3D Game World
- Animating Your Characters
- Building AI Opponents
- Machine Learning Algorithms for Game AI
- Continuing Your Learning Journey
To get the most out of this book, you should have a solid foundation in C++ programming, including an understanding of Object-Oriented Programming (OOP) and data structures. Familiarity with game-related concepts and knowledge, such as rendering, animation, physics, and frame rate management, will also be beneficial in understanding the practical applications of the algorithms introduced. While this book avoids overly complex modern C++ features, a basic grasp of C++ syntax and programming logic is essential for following along with the examples.
The following table outlines the software and hardware requirements for this book:
Software/Hardware Covered in the Book | Operating System Requirements |
---|---|
Microsoft Visual Studio 2002 with the C++ compiler | Microsoft Windows 10 and up |
If you run the samples on systems other than Windows, such as macOS, you will need to manually set up the project and copy the source code into the project.
If you are using the digital version of this book, we advise you to type the code yourself or access the code from the book’s GitHub repository (a link is available in the next section). Doing so will help you avoid any potential errors related to the copying and pasting of code.
Zhenyu George Li Zhenyu George Li is a passionate video game developer with over 20 years of experience in the field. As a seasoned software engineer, George has contributed significantly to the development of numerous games throughout his career and currently serves as a senior development engineer at Unity. George's fascination with video games was sparked during his college studies, igniting a passion that would shape his professional journey. During the early stages of his game development endeavors, George immersed himself in technologies such as Visual Basic, C/C++, DirectX, OpenGL, Windows GUI, SQL, and so on. These foundational experiences laid the groundwork for his subsequent success in the industry. Throughout his career, George has made substantial contributions to various commercial games. Notable titles on his portfolio include Unity demo and starter kit games, Sandbox, Halo Infinite, Magic Arena, Stela, Dead Rising 2, The Bigs 2, and others. His involvement in these projects has allowed him to gain extensive knowledge and practical experience in a wide range of domains, including programming, game engines, gameplay and AI, graphics, animation, multiplayer, game physics, frontend, and multiplatform. In practical applications, George has used Unreal, Unity, and some propriety game engines in the development of real game projects. In addition to his achievements as a game developer, George has also honed his teaching abilities during his eight years of college-level instruction. He has shared his knowledge and expertise with aspiring developers, serving as a lecturer at the Vancouver Film School, College of Interactive Arts, and Hefei Union University. While teaching at Vancouver Film School, George guided students through the intricacies of Unreal Engine, helping them build a strong foundation in professional game development.
Charles Shih-I Yeh Charles Shih-I Yeh pursued his computer science studies at the University of Southern California before embarking on a career in the video game industry in the early 2000s. He has held various pivotal roles in game programming, including building proprietary game engines, crafting Digital Content Creation (DCC) tools to streamline production pipelines, and designing engaging gameplay mechanics alongside robust multiplayer and MMORPG tournament services. Charles is also passionate and committed to sharing expertise and insights by delivering lectures on game programming at several esteemed universities. He is also the author of two game design books as well as the official translator of several famous game programming books, such as Game Programming Gems 4, into his native language, Mandarin.