32,39 €
Creating responsive, intelligent games takes more than just following engine tutorials. It requires solving real development challenges with practical, efficient code. This book bridges theory and practice with proven algorithms and techniques grounded in real-world production needs, emphasizing clean, portable C++ implementations.
Starting with raylib and the custom Knight engine layer, you’ll be introduced to a simple object-oriented scene and game object system. From there, you'll build responsive gameplay systems using essential data structures and algorithms, progressing through 2D rendering, collision detection, effects, and camera control before advancing to 3D graphics environments built using shaders, lighting, quad-tree terrain, and dynamic camera setups.
You’ll animate characters using skeletal rigs, interpolation, and inverse kinematics for fluid movement and then develop game AI using FSMs, behavior trees, A* pathfinding, and steering behaviors. The book also covers neural networks, exploring their underlying theories, training processes, and tools. Throughout, the code is written in legacy-compatible C++ to ensure broad support across platforms and compilers.
By the end, you’ll have gained the skills to build game systems that not only work but also scale, perform, and adapt like professional-grade code.
Das E-Book können Sie in Legimi-Apps oder einer beliebigen App lesen, die das folgende Format unterstützen:
Seitenzahl: 462
Veröffentlichungsjahr: 2025
Practical C++ Game Programming with Data Structures and Algorithms
Write high-performance code and solve game development challenges with expert-led C++ solutions
Zhenyu George Li
Charles Shih-I Yeh
Practical C++ Game Programming with Data Structures and Algorithms
Copyright © 2025 Packt Publishing
All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, without the prior written permission of the publisher, except in the case of brief quotations embedded in critical articles or reviews.
Every effort has been made in the preparation of this book to ensure the accuracy of the information presented. However, the information contained in this book is sold without warranty, either express or implied. Neither the authors, nor Packt Publishing or its dealers and distributors, will be held liable for any damages caused or alleged to have been caused directly or indirectly by this book.
Packt Publishing has endeavored to provide trademark information about all of the companies and products mentioned in this book by the appropriate use of capitals. However, Packt Publishing cannot guarantee the accuracy of this information.
Portfolio Director: Rohit Rajkumar
Relationship Lead: Neha Pande
Project Manager: Sandip Tadge
Content Engineer: Shreya Sarkar
Technical Editor: Kushal Sharma
Copy Editor: Safis Editing
Indexer: Pratik Shirodkar
Proofreader: Shreya Sarkar
Production Designer: Vijay Kamble
Growth Lead: Namita Velgekar
First published: June 2025
Production reference: 2110925
Published by Packt Publishing Ltd.
Grosvenor House
11 St Paul’s Square
Birmingham
B3 1RB, UK.
ISBN 978-1-83588-986-2
www.packtpub.com
I have known and worked with George Li in various capacities for more than 20 years.
We first met as colleagues at a private college of interactive arts in downtown Vancouver, Canada. I was a full professor of linguistics at a university in the area, with extensive experience in developing a cognitive science program at the university. Establishing a curriculum for such a program involved familiarizing myself with areas well beyond the area of my specific academic position and collaborating closely with colleagues – particularly in computing science (cognitive), psychology, and philosophy (particularly concerning socio-epistemological issues such as AI).
It was in this spirit that I was happy to associate myself with a private college, focusing on language study and teaching, together with preparing students to handle 3D computer applications (e.g., 3ds Max, 3D GameStudio, and Unreal) and showing them how to generate animation materials for film, TV, and games.
George Li was in charge of all the technical requirements of the college. I very quickly realized that he was not only extremely competent and forthcoming (he had already occupied high-level computing-teaching/-application positions, software engineering for instance, in China prior to emigrating to Canada) but also computationally competent and brilliantly innovative. He also had a particular interest in the development of game engines and was already collaborating with his colleague, Charles Yeh, on a practical reference book, XNA PC and Xbox360 C# Game Programming, with proprietary-produced text and games to his credit.
As colleagues in the college, George and I found common, mutually-strengthening interests. Eventually, he and I found ourselves in charge of creating a two-year interactive arts program curriculum for the college.
My whole career (at universities in the UK and Canada, and as a member of the editorial boards of a major academic journal and a very influential series) has closely involved the evaluation of the intellectual quality of people’s capabilities and work, and in my opinion, George Li’s innate talents shine out clearly throughout his work and will continue to do so in the future. His ability to express his knowledge of the subject at hand is outstandingly demonstrated in all his work, performance, expressions, and character.
This book, co-authored with Charles Yeh, is designed for independent developers, company training, and post-secondary reference use. The knowledge presented herein is most intelligently, clearly, and effectively presented so as to be as efficiently applicable and pedagogically effective as possible on any device or platform, producing high-quality games, accessories, and edits.
This volume will certainly stand the test of time and fulfill the majority of the needs of those working in the field of gaming. However, I am certain that George and Charles, working together, will make further, very crucial contributions to this topic.
Until then, this volume will serve you excellently, helping you enjoy and prosper with your future activities and products.
Dr. E. Wyn Roberts (M.A. Ph.D (Cantab.))
Emeritus Professor of Linguistics, Simon Fraser University, Burnaby, Canada
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.
I express my gratitude to my wife, Alison Guo, for her support in handling family responsibilities and for enabling me to dedicate time to completing this book. I also extend my thanks to Mike Oakes and my other colleagues for their encouragement and support throughout the writing process.
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.
I would like to express my heartfelt gratitude to my wife, Min-hwa Lee, for her unwavering support, and to my son, Phillip Yeh, whose encouragement means everything to me. My sincere thanks also go to my colleague, Mike Oakes, for his tireless dedication, as well as to all the technical reviewers and editors whose valuable feedback and commitment have been indispensable throughout this journey.
Michael Oakes is a software development manager for Unity who has worked in the games industry for 9 years, and in the IT industry for 27 years. Originating from Grimsby in the UK, he now lives in Calgary, Canada, and holds a Master’s degree in computer science and is a Certified Project Management Professional. He has worked with real-time 3D and games for over 9 years, specializing in mixed reality design and development, shader programming, and AI and multiplayer systems. Michael has worked as a technical consultant on several other titles, including Unity ML-Agents – Fundamentals of Unity Machine Learning, Practical AI on the Google Cloud Platform, and Unreal Engine 5 Game Development with C++ Scripting: Become a professional game developer and create fully functional, high-quality games.
First of all, I would like to thank my wife Camie for her support and patience for the time I spent locked away in my office conducting this book review, and also my late mother Sally, for her unconditional love and support in all my endeavors—my sister and I miss you dearly. Finally, I would like to thank Packt for providing the opportunity, support, and their trust.
Akhilesh Tiwari is director of production engineering at InvestCloud and has over two decades of software development experience. He obtained his MTech from BITS Pilani, India. Akhilesh has developed software solutions for the world’s leading organizations such as Merck, Novartis, BNY Mellon, Fujitsu, Cognizant, and Persistent Systems, to name a few. Akhilesh is a passionate software engineer. Even in his free time, he is hacking Raspberry Pi with his kids. Akhilesh now resides in New Jersey, USA, where he enjoys a fulfilling family life.
First of all, I would like to thank the Supreme Personality of Godhead, Krishna, for everything. I would like to thank my loving parents for their unconditional love and support. I would not have been able to do this book review without the support of my loving wife, Sanchita, and my two young ones, Osh and Radha. Last but not least, I would like to thank Packt for this opportunity and their trust.
In this part, the primary focus is on building a strong foundation in data structures and algorithms specifically tailored for game development. While many traditional algorithm books emphasize theory through pseudo-code, this part bridges the gap between theory and practice by offering real-world C++ examples that demonstrate how these core concepts are applied in actual game scenarios.
You’ll begin by exploring the essential role of algorithms in game design, and how they contribute to creating adaptive, high-performance, and engaging gameplay. From there, you’ll learn how data structures organize and manage game data efficiently, and how algorithms manipulate that data to drive meaningful in-game behavior.
Finally, you’ll dive into a curated set of practical algorithms—ranging from randomization and shuffling to procedural generation and object pooling—that are commonly used in game development projects.
This part includes the following chapters:
Chapter 1, Gearing Up: C++ for Game DevelopmentChapter 2, Data Structures in Action: Building Game FunctionalityChapter 3, Algorithms Commonly Utilized in Game DevelopmentA data structure organizes data for efficient access and processing. By itself, data is just raw information; to solve problems or reach goals, you apply a step-by-step procedure called an algorithm.
Much like any other computer program, a video game is composed of a set of data structures and the algorithms that operate on them.
Imagine a typical video game battle scene where you control a player character fighting against a group of NPC monsters. These monsters are essentially just data with attributes such as health points (HP). However, it’s the algorithm that drives the monsters to search for the nearest player-controlled hero and attack when they get close enough. In a video game, both data and algorithms must work together to create a fun experience. The way we arrange and store these data—through data structures—plays a crucial role in making algorithms work more efficiently.
This chapter will focus on the most common data structures needed to create a simple playable game (yes, you can complete a playable game as early as in this chapter).
In this chapter, we’ll cover the following main topics:
Data structures and algorithms in gamesDeciphering the secrets of game screenshotsEvaluating data structure and algorithmBasic data structure for collectionsThe order matters – LIFO and FIFOBy the end of this chapter, you will be able to implement a simple game with one-on-one fighting by using the data structures we have learned about.
Before downloading/cloning the sample project, please refer to the technical requirements in Chapter 1.
All demos for data structures introduced in this chapter can be accessed in the GitHub project at https://github.com/PacktPublishing/Practical-C-Game-Programming-with-Data-Structures-and-Algorithms/tree/main/Knight, specifically under these project names:
Project Name
Description
Demo2a
This project implements several different Entity classes to represent the player, enemy, and terrain.
Demo2b
