This course is for you if you are completely new to programming or the C++ language. This tutorial course will explain all you need to know to code C++ games as quickly as is realistic. This course will also be relevant if you wanted an introduction to C++ that was a bit more fun and a lot more visual than a typical C++ beginners guide.
There will be a whole range of game related mini-projects to accompany this course and you will be able to choose which ones you are most interested in completing. I would suggest however that you try out all the practical projects that are suggested throughout these tutorials as you will learn faster.
This course is also the place to start if you want to progress to learn to code for many different development platforms. For example C++ is the language of Unreal Engine and CryEngine the two most advanced game engines available. This C++ course will be especially relevant if you are an aspiring indie developer who wants to make super-fast 2d games; perhaps you want to get your game on Steam? C++ is the place to start. To accompany this C++ course there will be practical projects that use the SFML C++ library which is probably the best way for someone just starting game development who wants to make 2d games for any of the desktop operating systems. These mini-projects will lead to full working game projects.
This C++ course will assume you know absolutely nothing about C++ or any other programming language. It will explain all jargon as we proceed through each tutorial.
At times in the course, we will take an optional break from theory to do an appropriate project. These projects are hands-on real coding and are much more fun than theory. All the projects will be as game related as possible, including some full working games. The tutorial list here will grow over the coming days and weeks.
Explaining code through comments
Sometimes I will add extra explanation or clarification within the code itself. To do this I will use C++ comments. Whenever you see a line of code with two forward slashes- like this // at the start, that line of code doesn’t do anything except tell you something about the code. In our C++ programs, we will use comments to remind us of what different blocks or lines of code achieve. Here is what a comment looks like.
// I am just a comment and don't really do anything spaceShip.shoot(alien); // The line of code above shoots an alien // That was a useful comment wasn't it
Enough of all the introductions let’s get on with the tutorials.
The C++ game coding tutorials
The tutorials are designed to get you coding games as fast as possible. They are not fully comprehensive and some topics have been trimmed to the maximum. I am sure that the best way of learning to code C++ games; is to code C++ games. So the sooner we can start doing that the better. You will find that all of the practical C++ projects on this site come with loads of refresher information and of course lots of useful C++ comments using “//”. So don’t feel you need to master a topic before moving on. You can always refer back.
1 – Game Variables in C++
This tutorial introduces the fundamental C++ building blocks of our game, variables. The variables tutorial explains how we keep track of the state of our game when writing in C++. Variables can be everything from the players score to an entire level of our game. Let’s get started and learn about game data and variables in C++.
2 – Manipulating Game Variables in C++
This tutorial shows us the mathematical way in C++ that we can change our game’s data that is contained within our variables. After all, the player’s score does not remain static. Changing game variables in C++.
3 – Checking for conditions in C++
Now that we can use variables to represent all the vital data in our game we will see how we can test for important events called conditions within our game. How do we know when the player has lost their last life or achieved a new high-score? Find out about Checking for conditions in C++.
4 – Branching our C++ game code
Here we will use everything we learned about conditions and variables so far to make our game take a different course dependent upon an outcome. Learn about Branching our C++ game code.
5 – Looping our game code
In game coding, we will regularly want to execute parts of our code multiple times while making subtle or not-so-subtle variations to our C++ code on each pass. For example, each and every frame of our game is contained in just such a loop. This is how it works: Looping our game code.
6 – Organizing code with functions
Functions are the organizing blocks of our code. We can think of a function as a black box that does one very specific task and can be reused over and over. Learn how we organize our game code with C++ functions.
7 – Introducing OOP for C++ games
OOP is probably the most vital topic in modern game coding. How do we break down our planned game and the objects (like characters, spaceships, and levels) into its most appropriate constituent parts? Find out in this introduction to OOP in C++ game coding.
8 – Game data handling with C++ arrays
C++ arrays are what enable us to manage lots of objects in our game in an orderly manner. It is all well and good to have a well-designed object that can represent a zombie, an invader or a bullet; but what about when we need dozens, hundreds or even thousands of them? This brief tutorial solves the problem by learning about C++ arrays.
9 – Using C++ references to make code faster
When we pass values to a function or return values from a function that is exactly what we are doing. Passing or returning a value. What happens is that a copy of the variable’s value is made, and sent into the function where it is used. Nothing happens to the actual variable itself. C++ references allow us to work around this. But why would we even want to? Using C++ references to make code faster.
10 – Controlling game memory with C++ pointers
Pointers have a bad reputation. They can appear complicated or convoluted. Add to this, the way pointers can be used in C++ code has evolved in recent years. I believe the best way to understand them is to use them in their original (old-fashioned) form. You can’t understand how an internal combustion engine works if you go straight to a supercar. So what is a pointer? Controlling game memory with pointers.
Be sure to complete all the related SFML game projects.