Udemy
    •  
    •  
    •  
    •  
    •  
    •  
    •  
    •  
Turn what you know into an opportunity and reach millions around the world.
Learn More
Your cart is empty.
Keep shopping
Introduction to C++ for Game Developers
Rating: 4.6 out of 5(10 ratings)
163 students

Introduction to C++ for Game Developers

Build a 2D Game Engine from Scratch: Master C++ Fundamentals, OOP, and Modern Engine Architecture with SFML 3 and CMake.
Created byJoshua Kinney
Last updated 12/2025
English
English [Auto],

What you'll learn

  • Understand and correctly implement C++ variable declarations, common data types (including arrays, vectors, and maps), and I/O operations.
  • Use if/else statements, switch statements, and various loop structures (for, while, do-while) for game logic and iterative tasks.
  • Define, call, and manage functions, including the use of multiple parameters, returning values, and effectively employing enum types.
  • Explain the difference between Stack and Heap memory and the importance of manual memory deallocation on the Heap.
  • Use memory references (&) and raw pointers (*) to access memory addresses and pass variables to functions by reference for efficient modification.
  • Implement smart pointers to automatically manage memory and prevent common issues like memory leaks and cycling references.
  • Create effective C++ classes using member functions, class constructors, and class destructors to represent game objects and systems.
  • Utilize access specifiers (public, private, protected) to properly encapsulate data and functionality.
  • Implement core OOP principles, including inheritance, polymorphism, operator overloading, and manage the "Big Five".
  • Install and set up a C++ Integrated Development Environment (IDE) like Visual Studio or CLion.
  • Understand the C++ build stages (Preprocessor, Compilation, Assembly, Linking, Execution) and organize code using header files and forward declarations.
  • Use a build system (e.g., CMake) to create and link static and shared libraries, and integrate external libraries (like SFML) into a C++ project.
  • Set up the fundamental Application and World classes to create a basic game engine loop and project structure.
  • Define and integrate the Object class, along with key game systems such as Physics, Damage and Health, and an Asset Manager for loading resources.
  • Program enemy behavior (like chasing), manage collision, apply damage to player and enemy ships, and implement weapon upgrade mechanics.
  • Develop an in-game Head-Up Display (HUD) and User Interface (UI) elements, including kill counts, a health bar, and a game over screen.
  • Apply debugging techniques to fix common issues , implement a Sound System for background music and effects, and add visual polish.

Coding Exercises

This course includes our updated coding exercises so you can practice your skills as you learn.

See a demo
Image of coding exercise example

Course content

11 sections231 lectures20h 58m total length
  • Introduction1:56
  • Installing Visual Studio2:59

    Install Visual Studio Community 2022 for C++ development, choose desktop development with C++, and explore optional Unreal Engine and Unity integrations, downloadable from Microsoft.com.

  • Creating Visual Studio Projects2:07

    Create a new C++ project in Visual Studio 2022 by selecting an empty project template and a separate solution to host multiple C++ projects for Windows development.

  • Visual Studio Interface Overview3:10

    Explore the Visual Studio interface, including the menu bar, solution explorer, output window, git and version control, and toolbars, and learn to manage projects, files, and docking for efficient coding.

  • Creating New C++ Source Files2:44

    Create a new C++ source file named main, write int main with include iostream, and output hello world using std::cout and the insertion operator, and run to see the console.

  • Installing CLion3:25

    Download and install JetBrains Sea Lion on Windows, set the bin path, reboot, and configure file associations for CLion; Visual Studio offers an alternative workflow.

  • Creating CLion Projects4:57

    Create a new CLion C++ executable, explore CMake and MinGW defaults, view the hello world boilerplate, and compare Visual Studio workflow.

  • Project Configuration and Customizing the IDE3:07

    Modify your ide to improve readability by increasing the interface and font size in sea lion with alt shift plus, and set c++17 as the language standard in visual studio.

  • Declaring and Using Variables4:07

    Declare and initialize a std::string variable message with hello world, replace a hard-coded string in cout, and learn to run with an external console and optional cin input.

  • Exploring Common Data Types2:55

    Explore common data types in C++ including integers, floats, doubles, characters, booleans, and strings, and learn how to declare, output, and transform these values, including true/false and case distinctions.

  • Commenting Code3:20

    Learn to use comments in code, including single-line and multi-line formats, for debugging and task lists, and emphasize readable, self-explanatory code that speaks for itself.

  • Formatting Outputs3:19

    Learn to format outputs in C++ by using the insertion operator with cout, std::endl, and backslash n to create clean, multi-line messages from strings and variables, with spaces between objects.

  • Creative Output
  • Challenge Review: Creative Output6:27

    Explore how to craft a creative C++ output in a main function by using hero name, age, power, treasure, and rank, with the insertion operator and data types.

  • Declaring and Initializing Arrays2:18

    declare and initialize a string array named messages, a collection of data holding three items, using curly braces and commas, and access each element by its index.

  • Accessing Data in Arrays3:32

    Access array elements by index using square brackets, starting at zero, and understand static arrays with fixed size, out of bounds errors, and how to extend them before runtime.

  • Modifying Arrays1:54

    Modify a fixed-size array in C++ by indexing and assigning new values, such as hello learner at index zero, and learn initialization to avoid garbage data.

  • Calculating the Size of Arrays5:57

    Learn to determine an array size with the size of operator. Divide total bytes by type size to find the element count for char, bool, int, float, double, and string.

  • Adventures with Arrays
  • Challenge Review: Adventures with Arrays5:15

    Practice building a game character in c++ by defining name, class, and gold, managing a five-item string inventory (bow, arrows, health potion, map, torch), and displaying with zero-based indexing.

  • Declaring and Initializing Vectors1:51

    Declare and initialize a dynamic vector in C++ using std::vector<int> IDs. Vectors grow and shrink at runtime, unlike static arrays, and are initialized with curly braces and the = operator.

  • Accessing Data in Vectors1:53

    Access vectors in c++ using cout to display elements and practice front, back, and at for first, last, and middle values such as 10, 60, and 40.

  • Modifying Vectors6:04

    Learn how to modify a vector in C++ by pushing back values, inserting at front or specific positions using begin, end, and iterators, and erasing elements during runtime.

  • Getting the Size of a Vector1:12

    Learn to get the size of a vector in C++ with vector.size(), see how size changes when erasing, and note basic vector operations like resize.

  • Magic Shop Inventory
  • Challenge Review: Magic Shop Inventory6:46

    Learn to manage a game inventory in C++ with a std::vector of strings, add items with push_back, and display first, last, and middle items using front, back, and at.

  • Declaring and Initializing Map Types3:26

    Declare an associative map type using the standard library, with string keys and integer values, as demonstrated by the gamertags example.

  • Accessing Maps5:24

    Learn to access map types by key to retrieve values, contrasting with vectors, and check key existence with find and end to avoid default values from misspelled keys.

  • Modifying Maps3:05

    Learn how maps automatically sort by key, then insert a Neon Warden with id 1213, erase an entry, and clear the map during pagination while tracking the map size.

  • Mapping RPG Character Stats
  • Challenge Review: Mapping RPG Character Stats3:50

    Use a standard map with string keys and int values to store RPG character stats (health, mana, strength, agility, intelligence) and print them via key-based access with the insertion operator.

  • C++ Fundamentals: Core Syntax and Containers
  • Arithmetic Operators4:57

    Explore arithmetic operators in c++ for transforming data, including plus, minus, multiply, divide, and modulo, and learn practical uses like even/odd checks, cycling through ranges, and array indexing.

  • Assignment Operators2:38

    Learn assignment operators in C++ for game development, including simple equals and compound forms like plus equals, minus equals, times equals, divide equals, and modulo equals.

  • Increment and Decrement Operators2:51

    Learn how the increment and decrement operators work, including pre and post forms, with examples using cout and int variables, and how they behave in loops.

  • Comparison Operators2:55

    Learn how C++ comparison operators return boolean results using ==, !=, <, >, <=, and >=, and apply them in if statements and cout outputs.

  • Logical Operators6:04

    Learn how logical operators and, or, and not combine boolean expressions in C++ to evaluate conditions, with examples using a < b and a != b, and understand short-circuit behavior.

  • Operator Precedence6:03

    Explore operator precedence and order of operations, from parentheses to multiplication, division, modulo, and addition and subtraction, evaluated left to right. See how integers and floats affect results through casting.

  • C++ Fundamentals: Operators
  • Input Basics2:38

    Learn the basics of getting user input in c++, using cin and the extraction operator, store input in age, prompt with instructions, and echo back your age as feedback.

  • Handling Invalid Input4:55

    Learn how to handle invalid input in c++, using std::cin.clear and std::cin.ignore to reset the input stream and let the program continue.

  • Combining Inputs2:33

    Learn to combine multiple inputs in C++ by using getline to read a full name with spaces, and include the string library for proper functionality.

  • Ad Lib Adventure
  • Challenge Review: Ad Lib Adventure4:12

    Declare string variables for name, place, object, adjective, verb, and number; collect user input with getline; assemble and print a dynamic ad lib story in C++ for game development.

  • C++ Fundamentals: Input
  • Branching If Statements3:53

    Master conditional branching in C++ by using if, else if, and else to evaluate age-based conditions and drive messages, with examples of input and comparisons.

  • Logical Operators with If Statements4:24

    Explore using logical operators with if statements in C++, including and, or, not, and null checks, with age examples to show how conditions evaluate.

  • For Loops2:27

    Learn to use a for loop to repeat code while a condition holds, with an initializer, a condition, and an updater, cycling from zero to nine.

  • For Loop Variations2:47

    Explore variations of a for loop, including counting up and counting down, and the impact of different initializations and conditions. Learn how to avoid infinite loops.

  • Iterating Through Arrays1:51

    discover how to iterate through an array in c++ using a for loop, with the initializer, condition, and iterator advancing the index.

  • Controlling For Loops3:35

    Master for loops in c++ for game development by using break to exit early, continue to skip items, and apply modulo to filter even or odd numbers.

  • Avoiding the Off By One Error3:52

    Explains fixing off by one errors in for loops by calculating array length (size of numbers divided by size of int), avoiding <=, and embracing for range.

  • Range Based For Loops2:29

    Learn how to use range-based for loops in c++, replacing off-by-one errors with foreach-style iteration. Note c++17 limits and c++20 enhancements for forward and backward iteration, including begin and rend.

  • Using For Loops with Vectors3:10

    Explore for loops with vectors in c++, including iterator and range-based approaches. Learn to iterate forward and backward, manage size-based indexing, and compare vectors with arrays for looping.

  • Using Iterators to Traverse Vectors and Arrays5:23

    Explore traversing vectors and arrays with iterators, including begin, end, reverse iterators, and rbegin/rend. Compare for loops, auto, and C++17/20 approaches for forward and backward traversal.

  • Number Sequences with For Loops
  • Challenge Review: Number Sequences with For Loops2:41

    Apply for loops in c++ to generate number sequences: count up from 1 to a user-defined limit, print even numbers by twos, and count down from the limit to 1.

  • While Loops4:14

    Explore how the while loop uses a condition in parentheses, contrasts with a for loop, and waits for user input, exiting when the condition becomes false to avoid infinite loops.

  • Do While Loops3:26

    Learn how to use the do while loop to ensure it runs at least once, prompt for a number between 1 and 100, validate input, and loop on invalid entries.

  • Number Guessing Game
  • Challenge Review: Number Guessing Game5:15

    Review a C++ number guessing game solution using a constant secret number and input validation for 1 to 10, with a do-while loop repeating until the guess matches.

  • Switch Statements3:39

    Learn to replace long chains of if statements with switch statements in C++, using case labels, default handling, break to control flow, and cin/cout for user input and output.

  • Enum Type Basics3:59

    Explore the enum type in C++: a user defined type with named integer values, defaulting to zero through three, assignable values, and use in switch statements.

  • Casting Types3:18

    Master casting types in c++ for games, using static_cast to convert integers to enums, handle floats, and recognize when casting to strings is not possible.

  • Strongly Typed Enum Types2:45

    Explore strongly typed enum types using a scoped enum class to safely represent students like Josh, John, Mary, and Alan, accessed with double colon in a switch to handle cases and defaults.

  • RPG Battle Action Menu
  • Challenge Review: RPG Battle Action Menu7:02

    Define a battle action enum with attack, defend, magic, item, and run; display battle menu, cast the choice to the enum, and handle it with a switch and do-while loop.

  • Defining and Calling Functions3:03

    Define and call functions in C++, organizing code and enabling reuse by encapsulating logic, handling parameters and return types, and printing hello world inside the function.

  • Multiple Parameters in a Function2:39

    Learn how to pass arguments to a function in C++, using a string parameter like message, printing it for debugging, and handling multiple comma separated parameters with the signature.

  • Returning Values in Functions3:26

    Learn to return values from C++ functions, switch from void to int with the return keyword, pass parameters, and add two numbers before storing and printing the result.

  • Calling Functions from Other Functions2:07

    Call a function from another function to reuse code, define void say hello, pass parameters, and invoke add to output results like 60.

  • Function Declaration Order1:25

    Learn how function declaration order affects calls in C++. Place declarations above main to ensure functions are found and called correctly, preventing lookup issues when declaring after main.

  • Returning Vectors with Functions5:44

    Define a function that returns a std::vector<int> of random numbers, fills it with rand values using push_back and a seed, then prints them in main.

  • Passing by Value and by Reference5:31

    Explore passing by value and by reference in c++, comparing memory use and performance while sorting a vector of random integers with the standard sort, and using ampersand references.

  • Template Basics2:25

    Learn to use templates in c++ by turning print_message into a generic function that accepts any type with a parameter T. It prints values directly without converting to strings.

  • Vector Templates2:44

    Learn how to use templates to sort vectors of any type with a generic sort function using a template parameter T, and apply it to string vectors.

  • Variadic Templates4:47

    Explore variadic templates in C++, expanding a parameter pack with ellipses. Use a print message function with cout to output strings and numbers like hello and 42 gold.

  • Adventure Toolkit
  • Challenge Review: Adventurer Toolkit9:11

    Use templates to implement damage calculation, health restoration, and critical hit logic with a generic type T. Learn auto type deduction and a ternary operator to print combat results.

Requirements

  • A basic level of computer literacy (installing software, navigating file systems) and a commitment to learning a foundational programming language for advanced software development.

Description

This course is a comprehensive, project-based program designed to guide you through building a complete, functional 2D Game Engine and a game from the ground up using C++. Master modern C++ programming principles and apply them directly to create your own scalable game engine and a complete game using the SFML 3 library and the CMake build system.

Who is this course for?

This course is for developers who have a foundational understanding of programming and are looking to specialize in C++ for game development, transitioning from core principles to professional engine architecture.


Course Progression and Key Modules:

The curriculum is structured sequentially, moving from core language features to complex game systems:

  • Module 01: C++ Fundamentals: Solidify your foundation with a deep dive into core C++ syntax, common data types, control flow (If statements, Switch statements, Loops), functions, and standard data structures like Arrays, Vectors, and Maps.

  • Module 04: Object-Oriented Programming (OOP): Learn the core of professional C++ design. This module covers Classes, Constructors, Destructors, Access Specifiers (public/private), Inheritance, Polymorphism, Operator Overloading, and managing class member functions with Const and Static keywords.

  • Module 03: Memory and Pointers: Demystify C++ memory management. You will explore Stack and Heap memory, learn to avoid common issues like memory leaks, and master Smart Pointers (Unique, Shared, and Weak) for safe, efficient resource management.

  • Module 05: Building the Game Engine: This is the heart of the course, where you build the core architecture. You will install and configure the CMake build system, integrate the SFML graphics library, establish the project's structure, implement the main Tick and Render Game Loops, and design core engine classes such as Application, World, and the Actor base class.

  • Game Feature Implementation (Modules 06 - 11): Apply your engine knowledge to build out a full game:

    • Player & Projectiles: Implement player input, clamping movement to the screen, and creating owner-based projectile systems with their own movement logic.

    • Physics System: Implement basic Collision Detection, the Health Component, and enemy AI behaviors like Chasing and off-screen Spawning.

    • Damage & Health: Centralize damage settings, create a Ship Stats class, and implement the logic for applying damage to both the player and enemies.

    • Weapon Upgrades & UI: Develop features like Spread Shot, implement a system to track enemy deaths, and build the user interface, including the Main Menu, Game Over Screen, Kill Count, and Health Bar.

    • Debugging & Polish: Finalize the game with touches like basic player rotation, Camera Shake effects, and a complete Sound System for audio polish.

By the end of this course, you will have a fully working, self-built C++ game engine, giving you the practical experience necessary to tackle more ambitious projects.

Who this course is for:

  • This course is designed for individuals who have little to no prior experience with the C++ programming language but have a strong interest in game development and are ready to learn a complex, powerful language.
  • Absolute C++ Beginners: Students who have never coded in C++ or are looking for a comprehensive, structured introduction to the language's fundamental concepts, including variables, data structures (arrays, vectors, maps), control flow, and functions.
  • Aspiring Game Developers: Individuals whose primary goal is to build their own game engine or work on low-level game systems. The course directly transitions C++ fundamentals into building an application, world, and physics system.
  • Programmers from Other Languages: Developers experienced in languages like Python, Java, or C# who want to transition to C++ for performance-critical applications like game development, and specifically need to master manual memory management and object-oriented principles.
  • Students Ready for an In-Depth Study: Given the course's coverage of complex topics like memory management (Stack/Heap), raw and smart pointers (unique, shared, weak), and the Big Five of object-oriented programming, learners should be prepared for a rigorous, detail-oriented learning experience.