Fundamentals of 2D Game Engines with C++ SDL and Lua
4.6 (367 ratings)
Course Ratings are calculated from individual students’ ratings and a variety of other signals, like age of rating and reliability, to ensure that they reflect course quality fairly and accurately.
1,652 students enrolled

Fundamentals of 2D Game Engines with C++ SDL and Lua

Learn game development fundamentals with a simple 2D game engine and create one from scratch using C++ SDL and Lua
4.6 (367 ratings)
Course Ratings are calculated from individual students’ ratings and a variety of other signals, like age of rating and reliability, to ensure that they reflect course quality fairly and accurately.
1,652 students enrolled
Last updated 3/2020
English [Auto]
Current price: $121.99 Original price: $174.99 Discount: 30% off
5 hours left at this price!
30-Day Money-Back Guarantee
This course includes
  • 10.5 hours on-demand video
  • 14 articles
  • 20 downloadable resources
  • Full lifetime access
  • Access on mobile and TV
  • Certificate of Completion
Training 5 or more people?

Get your team access to 4,000+ top Udemy courses anytime, anywhere.

Try Udemy for Business
What you'll learn
  • C++
  • Object-oriented programming
  • Game engine architecture
  • SDL library
  • Embedding Lua scripts inside C++ applications
  • 2D game development
  • Game Development Fundamentals
Course content
Expand all 53 lectures 10:48:54
+ Introduction
1 lecture 09:11

This session covers the expectations and the learning outcomes of our course.

Preview 09:11
+ Dependencies and Project Structure
10 lectures 01:08:09

This session goes over the project dependencies and environment setup for Linux, MacOS, and Windows.

Project Dependencies

Let's quickly talk about our options to edit our course source code.

Choosing a Code Editor
Additional Links and Resources for Windows

Let's review our initial folder structure and the project tree.

Files and Folder Structure

Let's create a Makefile to help us build our project.

Quick Makefile Remarks

This is a quick walkthrough to go over the steps on how to install MinGW, SDL, and Lua under Windows.

Windows MinGW Installation

Attached is a resource with the Makefile that works for most Windows students.

Makefile for Windows using MinGW

Some students complained about a MinGW bug when using std::to_string function. Here is an alternative.

MinGW Error std::to_string

Let's try to build the project and see if all the dependencies are correctly installed.

Activity: Building the Project
+ Game Loop and Time Step
5 lectures 01:38:00

Implementing a very basic game loop.

The Game Loop

Making sure your game loop works with a consistent time step.

Fixing the Time Step
Using a Delay Function

Using the GLM to work with mathematical structures.

Using GLM to work with Vector2 values

This session reviews the flow of SDL rendering, including the idea of double buffering.

SDL Rendering and Double Buffering
+ Entity-Component Implementation
7 lectures 01:21:05

Here we cover the fundamentals of an entity-component game engine implementation.

Preview 16:11

Creating the headers for Entity and Component classes.

Entity and Component Prototypes

Creating the implementation for Entity and Component classes.

Entity and Component Implementation

Let's add a new function to add components and learn more about using C++ templates.

Working with C++ Generics

Just a generic cup...

Just a Generic Cup

Let's check if our entities and our components are running correctly.

Entities and Components in Action

Activity: Write a simple function that lists all entities and components that were added to our game.

Activity: List All Entities
+ Sprites and Animations
6 lectures 01:24:09

This session reviews the fundamentals of working with SDL sprites and images.


Let's create an asset manager that holds the textures of our project.

Managing our Assets

Implementing a new component to work with Sprites.

The Sprite Component

Activity: Write a function that checks if a certain entity has a component of a given type.

Activity: Function HasComponent

Implementing sprite animation.

Animated Sprites

This session shows how we can have an animation that contains several frames.

Example of Animation with Several Frames
+ Handling Keyboard Input
2 lectures 29:07

Let's create a new component that allows some flexibility for keyboard input.

The Keyboard Control Component

Let's write a couple of tests to keep the main player inside our game window.

Activity: Keeping the Player in the Window
+ Maps and Tiles
2 lectures 35:42

This session explains the basic ideas behind using tiles to build our game map.

Maps and Tiles

Let's create a new component to hold the functionality of map tiles.

The Tile Component
+ Layers and Camera Movement
2 lectures 30:58

Grouping entities by layer.

Working with Layers

Let's also add the idea of a 2D camera that follows our player.

Implementing a Moving Camera
+ Collisions
3 lectures 56:10

This session covers the basic implementation of collisions between objects.

Identifying Collisions

Activity: Add a "render" function to our collider component so we can also see the bounding box around the game objects that have a collider.

Activity: Rendering Bounding Boxes

Let's improve our collision check and discuss how we could reduce the complexity of our code

Improving our Collision Check
+ Text and Labels
1 lecture 27:36
The Label Component
  • Basic knowledge of the Linux command-line (creating directories, copying files, etc.)
  • Basic knowledge of programming fundamentals (variables, loops, functions, etc.)
  • Basic experience with a C-style OOP language (such as Java, C++, C#, etc.)

Do you want to be more than "yet another applicant that only knows Unity3D or Unreal"?

Or, do you want to really get your knowledge of C++ and object-oriented programming to the next level? And on top of that learn the fundamentals of how a simple 2D game engine works?

If that's the case... this course is for you!

We are going to implement, together, the basic architecture of a simple 2D game engine using C++, SDL, and Lua scripting.

Here is what we will cover:

  • The basics of a game loop and fixing our time step

  • Using the SDL library to handle graphics and hardware input/output

  • Loading dynamic entities to your game scene (enemies, vegetation, obstacles, etc.)

  • Creating a flexible tile-based game map

  • Adding components to your game objects:

    • Sprites

    • Animation

    • Transform (position, rotation, scale)

    • Colliders

    • Text labels

    • Projectile emitters

  • Managing game assets, such as textures, sounds, and fonts

  • Displaying UI text and HUD elements.

  • Using Lua language for scripting and configuring levels

...and so much more.

It is expected that you know the basics of the Linux command line (creating directories, copying files, etc). Also, a very basic knowledge of programming (variables, loops, conditionals, functions) and object-oriented principles will help you get the most out of this course.

You will be able to use the code developed in this course in Linux, macOS, and Windows. But, be aware that the lecturer does not use any IDE in this course and we will build our project using just GCC and Makefile directly via the Linux command line.

Join us, and learn the fundamentals of game architecture by creating a basic 2D game engine... from scratch!

Who this course is for:
  • Programmers curious about the fundamentals of game development