When game developers and software programmers talk about their favorite programming languages, it isn’t long before the rapid use of C++ in gaming.
It’s played a huge role in the coding of countless games, and has been among the most popular programming languages since its creation–all the way back in 1998!
But why is it that C++ has stuck around for so long? What video games in C++ have been made over the years? We’ll cover all that including how to learn game programming in C++, so let’s dive right in!
What Does C++ Do?
C++, like other programming languages, is used to write lines of code that give a computer instructions on what to do. Every video game, website, or piece of software uses these programming languages.
Though your average person may never see them, every time you hit a button on your controller, there are lines of code interpreting your button presses and producing a programmed response.
Written in 1998 by Bjarne Stroustrup as an improvement to the C language, C++ was created to be relatively easy to learn, highly adaptable to even modern programming standards, and most importantly: able to run high-level programs incredibly quickly. This explains why there are so many C++ games in the market nowdays.
It’s this speed that is its biggest selling point. How much of a selling point is it? Well, consider that Spotify, Google Chrome, and Youtube all use C++, and you begin to get an idea of its importance to the programming world. Some other benefits of game programming in C++ include:
Object-Oriented Programming, or OOP, is a part of the language that allows you to reuse code you have already written, by organizing it into different segments called “objects” or “Classes”.
This is a huge time saver when creating C++ games, as developers can quickly copy huge walls of code that they’ve already spent the time to write. You can even make subclasses within those classes so that you already have presets of written code, and how it interacts with other code, ready to go.
Not all programming languages use object-oriented programming, so it’s one incredible feature that makes C++ an essential tool for developers.
An Easy Middle Ground
As mentioned before, C++ is a fairly simple programming language to learn. Like any language, it has its own Syntax, but on average takes developers less time to get a read on than other programming languages.
It’s similar enough to Java and C# that if developers already know how to learn to program C++, they can easily switch over to those programming languages for the parts of development where they excel.
On top of that, C++ is a cross-platforming language, allowing your code to be compiled and made functional across multiple different gaming systems. Simply being able to use it anywhere makes it a great choice for developers to learn.
The C++ language allows for a process called “dynamic memory allocation.” This gives the developer much more control over how much memory is being used by their code, as well as system resources. This is part of what makes C++ game programming so convenient.
In other languages, the memory is allocated automatically, but this doesn’t give the developer the most amount of control over it, and means the language is doing more work to optimize the code, potentially slowing it down.
Since C++ has been around since 1998, it has had plenty of time to develop a massive community. A community that has had plenty of time to figure out and troubleshoot the language, tutorials on C++ game development and learning guides for new developers getting into it for the first time.
On top of that, C++ has actually remained supported. It’s most recent update was in 2017, with a new major update currently in the works.
The community around C++ game development has made the language far more accessible. Finally, because it’s used with such regularity, coders and video game development who are familiar with the language are always easy hires.
Is C++ the Perfect Language for Game Programming?
Even with all of these benefits, C++ in gaming isn’t the be-all and end-all. Most video games use several coding languages.
Developers switch to the programming language that works the best for the task they’re doing. For example, the Python programming language is widely considered to be the easiest programming language to learn. But, due to the shortcuts in the language that reduce the amount of code that programmers need to write, the computer has to do a lot more work to process what’s written, and it is a much slower language as a result.
In other words, C++ game development is often used when speed is the top priority, while other languages may be a better choice for developers when it is not.
Why is C++ Used for Games
Well, C++ has great performance. It is a compiled language, instead of an interpreted coding language, which makes it nearly as fast as the computer’s speed itself.
That’s mainly why C++ game development has nearly become the default for embedded code.
The Influence of C++ in Gaming
Video games can sometimes have hundreds of thousands of lines of code being processed by the games engine, and if the programming language used to write this code is too slow, it can impact a game’s experience.
Due to its speed, C++ has had the greatest impact on the creation of game engines. Unity, Unreal, and Frostbyte were all created using C++ game programming.
Anyone who’s even taken a passing interest in game development knows how influential Unreal and Unity have been to game makers. On top of that, most game engines can use C++ as well, making it possible not only to develop a video game engine, but a game to run off of it.
Examples of C++ Video Games
Well, the team at Blizzard was very familiar when it comes to creating games coded in C++ when they made World of Warcraft, the PC gaming sensation that took the world by storm.
Similarly, Grand Theft Auto: Vice City in particular a few examples of C++ video games.
Counter-Strike, Diablo 2, Doom–essentially if it is a AAA gaming title, the creators used C++ at some point during the development process. Games always want to run as fast as possible, and games made with C++ are looking exactly for that.
Here’s a list of popular games made in C++:
- Mortal Kombat 11
- Batman Arkham Origins
- Splinter Cell
- Unreal Tournament
- Half-Life 2
- Killing Floor
- Left 4 Dead
- Team Fortress
Online Resources to Learn C++ for Game Programmers
Want to learn by making games in C++? We assembled a few of our favorite tutorial resources so you can get started learning C++ game development immediately.
LearnCPP.com has “tutorials to help you learn to program in C++ and object-oriented programming.” Sounds pretty good, right? After all, that’s…kind of exactly why we’re here…
Anyway, this is a completely free website that guides you on how to learn C++. The site explicitly says that no prior programming experience is necessary.
When you visit the site, you’ll find that there are 18 chapters to scroll through, many with 10 or more lessons. They appear to be in the middle of rearranging the order of some of the lessons, but that shouldn’t pose too much of a problem.
You’ll want to learn all of this at some point anyway. If you find a lesson isn’t clicking, you can always skip it and go back.
The first chapter, “Chapter 0” is a full-blown introduction to more than just C++. There’s a lesson for using the tutorials, a lesson titled “introduction to programming languages,” a lesson on development, a lesson about common C++ problems, and more.
YouTuber Derek Banas
Derek Banas is a YouTuber who has a single tutorial video on C++ Programming. The idea is that he’ll cover everything you need to know about C++ for game programmers in a single, one-hour, and ten-minute video.
The convenience and expediency of “one video for everything” come at a cost: Banas doesn’t take any prisoners.
If you have no programming experience, this is not the video for you.
But, if you’ve had experience as a developer, or have any C++ game coding experience, this video could be a great refresher–and you might even learn some new things on the way.
Complete beginners should stay away, those with some experience can give it a shot and see if they can keep up. He shows you the commands and quickly and simply explains why he’s doing what he’s doing, but there’s no coddling.
It’s less like Banas is holding your hand, and more like Banas is sounding his location by snapping his hands in a dark room. If you’re familiar with the room(or C++) it will be a lot easier for you to track his location (or keep up with a C++ game tutorial).
Game programming in C++ tutorials over at Tutorials Point seem pretty solid. The syntax is a little wonky in spots, but not in a way that makes the text-based tutorials hard to understand.
It’s a missing article here or there, or an inverted phrasing–the kinds of slipups that come with learning English as a second language, and getting pretty dang close to mastering it.
A neat feature involves the practice examples featured in the tutorials. There’s a “Try It” option in the majority of the C++ example boxes. When you click on that, it brings up an in-browser window with the complete C++ code from the example on top and the executed code on the bottom.
You’re able to delete the code in the top box and input the code from the example yourself. Then you can hit “execute” and the window will run your code, showing you whether or not you input the code correctly. It’s convenient if you aren’t trying to save or compile all of your completed examples.
This website has tutorials for getting started with C and C++. If you’re looking for ways to learn how to code a game in C++, the author of the site recommends you buy his ebook, titled “Jumping into C++,” as he claims it’s a more complete tutorial guide than the free tutorial he provides online.
You might want to give the free tutorial a stab before you go dropping money on an ebook. Or go back and check out the LearnCPP tutorial at the beginning of this guide before tapping into the tutorial at Cprogramming.
Aside from covering different C++ topics, the site also has a “practice” section. You can solve practice problems and take quizzes to test your C++ programming knowledge.
The site’s author also built a “resources” section. This has links to the source code page, source code snippets page, C++ tips page, and even a “finding a job” page.
All in all, there’s a healthy dose of information available here, and there are some resources outside of the standard tutorials on C++ for game programmers to help you hone your C++ skills. As you become more familiar with C++, give this site a look.
Udemy has a free tutorial on how to learn C++ for game development” It’s a course that shows “how to program in the popular (and tricky!) C++ programming language, for complete beginners.”
Enrollment in this course is free. Despite the lack of a price tag, or maybe because of it, it received an average of 4.5 out of 5 stars (from 5,001 ratings). Over 75,800 students have enrolled in the history of this particular course.
The course assumes only basic computer knowledge. You do need to be computer literate, but you don’t need to have programming experience.
The course creator, John Purcell, calls C++ a tricky language, so he encourages you to bring both your patience and persistence.
By the end of the course, you’ll be able to develop C++ programs and even apply to C++ jobs with some potential for success. No guarantees, but this course certainly won’t hurt your chances.