Course description

c++ game engine

This course is a gentle and comprehensive introduction to the fundamentals of 2D game engine architecture. We'll discuss several of the most popular programming patterns used in game development and try to put all the theory we learn into context by coding a small 2D game engine using modern C++, SDL, and Lua.

c++ ecs

We will write, together, a small ECS framework from scratch to manage our entities, components, and systems. We will discuss how engine programmers design their code and how we should think of organizing game objects in memory with performance in mind.

The tools you'll need

c++ game engine tools
  • C++ is a powerful compiled language
  • SDL2 is a library for cross-platform rendering and input
  • GLM is a math helper library
  • Dear ImGui is a library to create UI for engine tooling
  • Sol is a binding library for modern C++ & Lua
  • Lua is fast and easy to use scripting language

We'll try to write most of our engine code from scratch. All these libraries and tools are cross-platform, so you'll be able to code along with either Windows, macOS, or Linux!

c++ game engine platform

Is this course for you?

The target audience for this course are beginner programmers that wish to learn more about how C++ works in the context of game development. Therefore, students must already know how to code and be familiar with basic concepts of programming and logic. You should be able to write if-else statements, loops, functions, and classes using simple OOP.

You do not need to know C++ before enrolling; many successful students have a background in web, mobile, and game development, working with languages like Java, Python, Ruby, Go, Swift, JavaScript, Ada, Zig, Kotlin, and many others.

How is this course different?

This course is not just a simple tutorial on how to create a game with C++. This is the opportunity for you to think about the abstraction of what a "game" really is and all the pieces that need to interact to make them happen. More than that, this course allows you to write from scratch the code of a small C++ engine that can be used to create many types of games.

We will also touch other important topics like ECS, data-oriented design, STL containers, C++ templates, game loop, SDL rendering, event systems, asset management, memory management, and performance. And finally, we'll also learn how to embed the Lua language into our native C++ code to add scripting power to our engine.

lua game scriptingr

While there are other resources about game engine development out there, they are either too theoretical or overwhelmingly long. If you are looking for a gentle introduction to the world of game engine programming and want to learn how games really work under the hood, then you should definitely take this course!

About the instructor

gustavo pezzi

Gustavo Pezzi is a university lecturer in London, UK. He has won multiple education awards as a teacher and is also the founder of

Gustavo teaches fundamentals of computer science and mathematics; his academic path includes institutions such as Pittsburg State University, City University of London, and University of Oxford.

teaching certification
higher education academy
pgclt teaching certification
bpp university award

Course content

30 hours total length 27 Chapters Last updated January 2022
  • Motivations & Learning Outcomes
  • How to Take This Course
  • Project Technologies and Libraries
  • Configuring Linux Dependencies
  • Configuring macOS Dependencies
  • Compilation
  • Linking
  • Makefiles
  • Configuring Visual Studio on Windows
  • Quiz: Compilation and Linking
  • Static vs. Dynamic Libraries
  • Game Loop
  • Game Class
  • Creating an SDL Window
  • Polling SDL Events
  • Rendering the SDL Window
  • Fullscreen SDL Window
  • Fake Fullscreen vs. Real Fullscreen
  • SDL GPU Acceleration and VSync
  • Quiz: SDL Window
  • Drawing an SDL Rectangle
  • Double-Buffered Rendering
  • Loading PNG Textures
  • Quiz: Game Loop and SDL Window
  • Object Movement and Velocity Vectors
  • Fixed Game Framerate
  • SDL Delay
  • Variable Delta Time
  • Uncapped Framerate
  • Game Loop and Determinism
  • Quiz: Game Loop Timestep
  • Logger Class
  • Exercise: Logging Game Information
  • Coding the Logger Class
  • Popular C++ Logger Libraries
  • Quiz: Logger
  • Project Subfolders
  • Makefile Variables
  • Creating C++ Objects
  • Examples of C++ Object Creation
  • Organizing Game Objects
  • Object Inheritance Design
  • Quiz: C++ Objects
  • Component-Based Design
  • Entity-Component-System Design
  • ECS Folder Structure
  • System Component Signature
  • Working with C++ Templates
  • Component Type Template
  • Understanding Component<T>
  • Exercise: System Functions
  • Adding and Removing Entities from Systems
  • The Erase-Remove Idiom
  • Operator Overloading for Entities
  • Quiz: ECS Design
  • Pool of Components
  • The Pool Class
  • Coding the Pool Class
  • Registry Systems & Entity Signatures
  • Entity Creation
  • Adding Components
  • Removing Components
  • Implementing System Functions
  • Quiz: ECS Implementation
  • Creating our First Entity
  • Smart Pointers
  • Converting ECS Code to Use Smart Pointers
  • Raw Pointers for SDL
  • Quiz: Smart Pointers
  • Adding our First Component
  • Careful with Types size_t and int
  • Exercise: Entity Class Managing Components
  • Entity Class Managing Components
  • Warning About Cyclic Dependency
  • Movement System
  • Movement System and Delta Time
  • Render System
  • Managing Game Assets
  • The Asset Store
  • Displaying Textures in our Render System
  • Exercise: Displaying the Tilemap
  • Displaying the Tilemap
  • Rendering Order
  • Sorting Sprites by Z-Index
  • Animated Sprites
  • Animation System
  • Identifying Animations By Name
  • Entity Collision Check
  • Implementing the Collision System
  • Exercise: Rendering a Collider Rectangle
  • Quiz: 2D Collision
  • Killing Entities and Re-Using IDs
  • Implementing Entity Removal
  • Introduction to Event System
  • Event System Design Options
  • Event Handlers
  • Emitting Events & Subscribing to Events
  • Exercise: Key Pressed Event
  • Event System Design Patterns
  • Quiz: Event System
  • Keyboard Control System
  • Camera Follow System
  • Sprites with Fixed Position
  • Projectile Emitter Component
  • Projectile Duration
  • Health Component
  • Exercise: Shooting Projectiles
  • DRY Code
  • Tags & Groups
  • Optimizing Access of Tags & Groups
  • Projectiles Colliding with Player/li>
  • Projectiles Colliding with Enemies
  • Compilation Times
  • Data-Oriented Design
  • Cache Hits and Cache Misses
  • Avoiding Data Gaps
  • Packed Pool of Components
  • Array of Structs vs. Struct of Arrays
  • Cache Profiling with Valgrind
  • Popular C++ ECS Libraries
  • Adding Fonts to the Asset Store
  • Render Text System
  • Exercise: Rendering Health Value
  • Introduction to Dear ImGui
  • Dear ImGui and SDL
  • Dear ImGui Demo Window
  • Immediate-Mode GUI Paradigm
  • Render GUI System/li>
  • Button to Spawn Enemies
  • Exercise: Customization of New Enemies
  • Quiz: Dear ImGui
  • Killing Entities Outside Map Limits
  • Flipping Sprites on Collision
  • Invisible Entities & Obstacles
  • Exercise: Keeping the Player Inside the Map
  • Culling Sprites Outside Camera View
  • Game Scripting
  • The Lua Scripting Language
  • Using Sol as a C++ Lua Wrapper
  • Lua State
  • Reading Lua Tables
  • Fetching Missing Table Values with Sol
  • Lua Functions
  • Level Loader Class
  • Reading Assets from a Lua Table
  • Handling Multiple Objects in a Lua Level
  • Scripting for Night/Day Tilemap
  • Scripting Entity Behavior with Lua
  • Script System
  • Lua Bindings
  • Binding Multiple Lua Functions
  • Loading Different Lua Levels
  • Division of C++ and Lua Code
  • Quiz: Lua Scripting
  • Finishing our Code
  • Next Steps
  • Proposed Project: Tilemap Editor
  • Moving Forward
  • Copyright & Content Distribution

What students are saying

5 star
4 star
3 star
2 star
1 star
"Fantastic course! Incredible lectures packed with amazing nits and bits about game development and high-performance software development. Can't wait for the next one :) Would easily recommend this to anyone that is passionate about Computer Science and "how things work". Thanks, Gustavo!"
02 Mar 2023
Waldemar Zeitler
"Well understandable introduction to game engine programing. This course was very understandbale, even with all the C++ shenanigans and all lead to a good starting point for further personal development. So I definitely recommend this course for all C++ users!"
01 Mar 2023
Ramtin Javanmardi
Data Engineer @ Mentimeter
"Im actually surprised how good this course is not only for learning game engine programming fundamentals but also c++ programming concepts. Sensational work!"
25 Feb 2023
Aitor SF
Aitor SF
"Okay as first introduction to game engines. I like that Gustavo keeps things simple to teach the fundamentals of how game engines are architected. It explains in depth hims code and the course is very well structured. I recommend it if you want a gentle introduction.

However, I want to give a small improvement feedback. I think that a lot of effort is being made on teaching c++. The course would be more interesting reducing the number of videos explaining the c++ lenguage. Learning c++ is a big topic and try to fit teaching c++ is a waste of resources that could be spend into more game engine related topics like creating an editor. It would be better if people only take this course knowing at least the very basics of c++. Also the way c++ is used in this course should not be taken as an example. The use of shared pointers are totally unnecesary, they seem to be there only to teach people about their existence (again a c++ topic). There are too many memory allocations and copies being performed. I would agree the main point of the course is not performance. And I like the course is in c++ because it is what game engines at the core use. But if we don't need performance, why would we use c++ in the first place?

Improvement points:

- The type of components that exist is are known so we can save allocations using a plain array.When we run the game the engine already know all the types of components that exists. This only changes during development. We could use a simple enum to keep track of this and resize the array at compile time. This way you don't need to allocate which is expensive.

- The number of types of systems are known as well. This only changes in code during development so not need of vector usage here.

- Reduce the use of shared pointers. Most of the time we only need to modify an object in the registry. We can return a reference to the underlying object to change it.

- The Pool class is just a wrapper to a vector we could just typedef vector.

- The maximum number of components is known, in this case 32. We can use an array of 32 lenght on the stack for each pool.

- We can replace the Pool class for a more advance data structure like a free list to manage adding entities.

- We do not need to remove systems at all."
19 Feb 2023
Paolo Astolfi
Paolo Astolfi
"A really great course with a fantastic teacher! This is the best online course I have ever attended. I have learned a lot and enjoied programming with Gustavo. I have already started the Game Physics Engine Programming course and after that I will also take the 3D Computer Graphic Programming course. Really good stuff!"
06 Feb 2023

Other similar courses

3D Computer Graphics Programming

35 hours
  • Create a 3D software renderer from scratch using the C programming language.
raycasting texture c

Raycasting Engine Programming with C

18 hours
  • Write a raycasting engine with textures and sprites using the C programming language.

Game Physics Engine Programming

35 hours
  • Learn how to create a 2D rigid-body game physics engine from scratch with C++.