Game programming is an exciting and valuable skill to learn. If you have ever played a video game before, it’s likely you have come to ask yourself “just how are video games made?” or “how can I go about making a video game myself?”. Since you have now come here to learn, it looks like you finally caved in to that curiosity. I presume that you really want to learn what video game programming and development is all about – down to the very core of the topic. This is not one of those quick 30-minute tutorials to show you how to become the next game development prodigy. It is a learning path laid out for you to follow over time if you truly want to understand the topic in depth.
There are no prerequisites to start your journey on this path, as long as you are patient, dedicated, and above all, willing to learn. That said, this is also for those of you that have made a small game or two, but have come to desire a deeper understanding to hone your skills and improve your work.
Become a proficient programmer
The first point on the path, and perhaps one of the most important, is to make sure you have a good grasp of computer programming and computer science in general. If you already have a background with programming, that’s great. If not, that’s okay as well, you’re just going to have to work a little harder to make sure you understand the material you will be going through. Game programming is as much programming as any other type of programming. All the logic (the rules essentially) of your game and its surrounding world have to be defined through programming. This may sound daunting if you have never programmed before, but soon you will realize that it’s an extremely useful, and even fun, skill with very few limitations.
You may be tempted to try to make games without programming, this might work out for you in the short run, but if you really want to understand game programming you must be willing to get down to the nitty-gritty and learn to program.
If your programming experience is limited, it is highly recommended that you try to learn some basic programming skills before you delve deeper into game programming. The good news is that you can learn game programming and general computer programming at the same time. As you get into the more advanced topics however, things will be a lot easier if you have a good fundamental understanding of computer science and programming. Try to evaluate this for yourself, there is no path set in stone.
Choose a known game engine – or don’t
Game engines are development environments that help you to develop your game. They provide functionality such as 3D and 2D graphics rendering, a physics engine, audio support, animation, collision detection, and networking.
There is plenty of discussion and debate as to which game engine you should use. If you are set on using one of the big game engines I recommend that you use the Unity game engine. The Unity game engine has plenty of good resources to learn from, is fairly easy to learn, and is free to use (until your company passes $100,000 in revenue/funding). If you decide to choose another game engine that is fine as well. The most important thing is that you stick with your engine of choice until you know a game engine well enough to rely on it for your future game projects. That said, it’s always good to explore what different game engines have to offer, and you can certainly learn a lot from doing that.
Now, you might be asking, do I really have to use a game engine? Absolutely not. Game engines are extremely helpful in giving you the productivity you need to make video games. However, much can be learned from developing a game without the use of a game engine that does the bulk of the technical work for you. In fact, I highly recommend that you try to develop at least some games without relying on a big game engine like Unity, Unreal Engine, and so on. This will be much preferred later on when you have to implement some of the crucial design patterns used in game programming yourself. The big engines already have this sorted out for you – resulting in you missing out on valuable learning opportunities.
Since you are just starting out however, I do recommend that you use an established game engine such as Unity, Unreal Engine, or Godot (and many others). This will help you get your feet wet and get a taste for what game development has to offer.
If you don’t want to use a game engine, consider using a multimedia programming library such as SDL or SFML. This will only provide you with basic functionality, but often that is all you need when you are building simple games.
If you want to learn Unity and prefer to learn from books, I highly recommend “Unity in Action” by Joseph Hocking, from the good folks over at Manning Publication (who I believe always deliver high-quality programming books).
Steps to take
- Choose a game engine that you will stick to throughout your learning path. If you don’t know which engine to pick then go with Unity.
- Learn the basics of what the engine has to offer. Go through to learning material, read articles, watch videos, practice and experiment.
- Make your first small but real game. I know – you’re going to have a ton of ideas and ambitions for your game, but for now you’re still learning to crawl. Keep the project small in scope, it should be something you can complete in a few days or a week at most (think Snake, Tetris, a simple platformer, etc.). The most important thing is that you finish it, even if it’s not going to live up to your ambitious expectations. Make sure the game has a clear purpose and fail state (e.g. a game over screen) so that it’s nicely tied up and feels like a real video game, not just another tech demo.
Once you feel ready go on to the next section, here things will finally start to get more in depth.
When we develop video games we tend to follow a set of tried and tested patterns that will aid you in designing and structuring your code. These are design patterns and there are a handful of them you would be wise to learn and to apply to your game.
When programming a game, design patterns help us to keep the complexity of the code down, while at the same time giving us a clearer way to conceptualize the logic of our code. To give you an idea of what these design patterns really are, let’s take a look at one of the popular design patterns in video games, the component pattern.
With the component pattern, things in your game are made up of reusable components. Imagine all the physical objects in your game, they need to be rendered and displayed on the screen with their appropriate 3D model (or 2D sprite). If we have a reusable ModelComponent, we can add it to any object which we want to be able to render. Furthermore, it also gives us the ability to easily remove a component if we no longer need it to be rendered. This saves you the trouble of rewriting code and it lowers overall complexity. It gives you flexibility in changing your game world on the fly. Don’t need to render that enemy anymore? Simply remove the ModelComponent from the enemy.
Steps to take
- Read “Game Programming Patterns” by Robert Nystrom. This excellent book is available for free online or alternatively purchasable in print on Amazon.
- Make a game or a series of small games that aim to implement some of these different design patterns. The games should be small in scope as to not overwhelm yourself, while focusing on the programming techniques you are learning. I recommend the component, prototype, and observer patterns as these are widely used. However, you should choose the ones you find most useful and fitting for your game idea.
- Once you have implemented some of the design patterns, sit down and evaluate the impact it had on your game and codebase. What are the pros and cons of a given pattern? What situations would it benefit you to use a given pattern – which would not? Write down a short summary of the pattern. Do this for at least 3 of the patterns in the book.
Optionally: Read the book “Design Patterns: Elements of Reusable Object-Oriented Software” . This is a Computer Science classic that explains a lot of common design patterns used in general computer programming. This is a heavier read so it is completely optional. However, if this sort of thing interests you and you want to dive deeper, this book is a great opportunity for you to do so.
3D graphics and the underlying mathematics
The graphical part of video games is one of the most important. What exactly constitutes a video game is hard to define – but generally all video games need graphics to display information to the player, while they may not necessarily need sound, networking, or other functionality. Learning about computer graphics and the mathematics surrounding it is key to becoming a better game programmer, even more so if you are going to make a game without relying on an already-made game engine.
Even if you use a game engine like Unity, at some point you will most likely need to write your own shaders. You can use the engines built-in shaders – if you want to make things stand out visually however, you need to write custom shaders. Do not be discouraged, as learning to write shaders can be a lot of fun. There are in fact whole communities based on writing and sharing their cool shaders. Check out Shadertoy and GLSL Sandbox.
The mathematical aspect of 3D computer graphics is largely based on the principles of linear algebra. Linear algebra is concerned with linear equations and their representations with matrices and vector spaces (read more on Wikipedia). This is an important mathematical topic to understand – at least in part, as it is a big topic in and of itself. It is with vectors and matrices we can model and manipulate the 3D world of our games (even if your game is 2D, as those typically reside inside a 3D space).
Steps to take
- Learn the basics of linear algebra and its use in video games and computer graphics. I recommend the MIT OpenCourseWare 18.06 Linear Algebra course along with the book from the same professor: “Introduction to Linear Algebra” by Gilbert Strang.
- Implement one or more custom shaders. Feel free to experiment and create something creative. The point is for you to get familiar with shaders, not to become an expert at them just yet. That comes with practice and continuous use. You can use the shader language of your engine of choice – or you can use something like GLSL with OpenGL if you are feeling up for a challenge and want to code games without a game engine. Learning OpenGL or a similar graphics API is definitely recommended for self-learning game programming.
Understand how game engines work
This is where things start to get more technical, but also much more rewarding and valuable. To really get a deep understanding of game programming it is time for you to learn more about how game engines work.
One of the best ways to learn about something is to make it yourself. Now, as a word of warning, you must realize that game engines are huge undertakings. It is unrealistic to assume most people will have the time or dedication to complete a game engine. Fortunately, the point of doing this is not to make the next big Unity or Unreal Engine. The point is to understand the ideas underlying the functionality of game engines by building a small game engine yourself. You want to build a set of commonly used functionalities (graphics, input, sound, etc.) that will aid you in developing games.
You should be able to use your previous knowledge of 3D graphics programming to build your engine. At first that is where the bulk of the work will be. As you go on and further develop your engine, you can start thinking about adding sound, networking, or other advanced features.
At this point in your learning path, I believe you are well enough equipped to approach this problem in a variety of ways. Some of you will feel like you are ready to dive straight into the action and start building your engine already. If you are eager to get started, I recommend that you do so by developing your game engine while studying the theory alongside. I highly suggest that you read “Game Engine Architecture” by Jason Gregory. This book is a heavy read, clocking in at just over 1000 pages. I cannot recommend reading it in one sitting. This is the sort of book that you slowly consume over the months, if not years (remember, we are serious about learning this). Read as you are going along with your project. Take notes and apply what you are learning to your own project.
Alternatively, consider the “Foundations of Game Engine Development” book series by Eric Lengyel. These books cover the mathematics, rendering, animation, and physics needed in a game engine. Note that at the time of writing this not all of the books have been released yet. So far, the books are looking promising however.
Steps to take
- Create a small game engine with basic functionality such as 3D (or 2D if you want to keep it simple) rendering, model / sprite loading, player input, and some kind of object system (think back to Design Patterns and the component pattern).
- Make a small game using your own game engine. This is when you will really have to refine your engine to make sure it lives up to the task.
Hopefully this learning path has taught you what you need to do to become a better game programmer. I hope you stay on the path and keep on learning. If you have any questions or suggestions feel free to leave a comment below!