• 2D shoot 'em up
The Legend of Edgar 1.37
SDL2 Santa game tutorial 🎅
SDL2 Shooter 3 tutorial
The Legend of Edgar 1.36
SDL2 map editor tutorial [UPDATED]
SDL2 Game Tutorials
This series of tutorials focuses on creating games using SDL2. The tutorials are split into several parts, to make it easier to understand the steps involved and not to overload the reader with information from the start.
Note: These tutorials assume that you are already familiar with C programming and you are comfortable with advanced topics such as pointers, as well as using CMake and Makefiles. You are also advised to follow the tutorials in order, rather than just jumping around as prior knowledge is assumed throughout. You can read more about setting up SDL2 on the API's wiki page: https://wiki.libsdl.org/Installation.
The SDL1 tutorials have moved here. Since these use SDL 1, they are considered out of date and it is suggested you use the SDL 2 tutorials instead.
(* - if using an IDE, plugins may be available to support cmake without requiring any downloads by the user)
These tutorials use cmake to build. You may build them in one of several ways:
cmake CMakeLists.txt make
This will generate the make file and all build-related data in the same directory as the CMakeLists.txt file. While this is the simplest approach, it does result in all the cmake files being created alongside the other assets. It is the fastest way to get going, however, and the approach taken in the tutorial listings.
mkdir build cd build cmake .. cd .. make -C build
This is a much neater approach, as all the cmake related build data is stored in a directory called "build". The downside is that it requires some extra steps on behalf of the user. Actual compiling also needs to be performed by either changing into the build directory before running make, or by using make -C build to tell make to work with the build directory.
Via your IDE
An IDE such as VSCode has support for cmake, and may have its own rules as to where it creates the build data, and how it compiles. So long as it respects the rules within the CMakeLists.txt, this shouldn't be an issue.
In all cases, the resulting binary will be produced alongside the CMakeLists.txt file, and relative to the required assets (data, gfx, sound, music). If you are using an IDE, ensure the binary is produced this way, as it will expect to load data relative to its location. If not, you will likely find the binary won't run, as it will fail to load any assets.
The full source code and assets for all the listed tutorials is available for purchase.
You may purchase the complete set of tutorials from itch.io, using the link below.
You can also download some of the games created by these tutorials by clicking here.
Creating a 2D shoot 'em up
This tutorial will show how to create a simple 2D shoot 'em up, starting with opening a window, all the way to building a highscore table. If you're new to SDL2, this would be a good place to start.
Creating a 2D top-down shooter
This tutorial will show how to create a simple top-down 2D shooter that we're going to call Battle Arena Donk! Mouse controls will be used extensively throughout.
Creating a 2D platformer
Learn how to create a simple multi-scrolling 2D platformer, code-named Pete's Pizza Party.
Creating a sprite atlas
In this tutorial, we'll demonstrate how to create and use a sprite atlas.
Working with TTF fonts
In this tutorial, we'll demonstrate how to use SDL2 TTF for text rendering.
Creating a simple 2D adventure game
Learn how to make a basic 2D adventure game.
Creating a basic widget system
Learn how to make a widget system, for use with in-game menus.
Creating a 2D vertical shoot 'em up
Learn how to create a vertical 2D shoot 'em up, that includes power-ups and enemy attack patterns.
Creating a 2D run and gun game
Learn how to create a 2D run and gun game, like Contra, Turrican, and Duke Nukem.
Creating a roguelike
Learn how to create a simple roguelike.
Creating a lookup system
A short tutorial on how to make a key-value lookup system.
Creating an in-game achievement system
Learn how to create an achievement system, known as Medals.
Creating a simple 2D turn-based strategy game
A tutorial about how to create a 2D turn-based strategy game.
Making a 2D isometric game
A tutorial about how to create a 2D isometric game, in an old-school flip-screen style.
Making a basic 2D map editor
A tutorial about how to create a basic 2D map editor.
Making a mission-based 2D shoot 'em up
Learn how to create a mission and objective-based 2D multi-directional shoot 'em up.
Making a 2D Santa game
Learn how to create a simple Santa game to celebrate Xmas!
Binary downloads (Linux + Windows) for some of the tutorials included here: