Beginning C++ Game Programming - Part 1
3.7 (32 ratings)
Instead of using a simple lifetime average, Udemy calculates a course's star rating by considering a number of different factors such as the number of ratings, the age of ratings, and the likelihood of fraudulent ratings.
139 students enrolled
Wishlisted Wishlist

Please confirm that you want to add Beginning C++ Game Programming - Part 1 to your Wishlist.

Add to Wishlist

Beginning C++ Game Programming - Part 1

Learn C++ from scratch and get started building your very own games
3.7 (32 ratings)
Instead of using a simple lifetime average, Udemy calculates a course's star rating by considering a number of different factors such as the number of ratings, the age of ratings, and the likelihood of fraudulent ratings.
139 students enrolled
Created by Packt Publishing
Last updated 1/2017
Current price: $12 Original price: $125 Discount: 90% off
3 days left at this price!
30-Day Money-Back Guarantee
  • 6 hours on-demand video
  • 1 Supplemental Resource
  • Full lifetime access
  • Access on mobile and TV
  • Certificate of Completion

Training 5 or more people?

Get your team access to Udemy's top 2,000 courses anytime, anywhere.

Try Udemy for Business
What Will I Learn?
  • Get to know C++ from scratch while simultaneously learning game building
  • Learn the basics of C++, such as variables, loops, and functions, to animate game objects, respond to collisions, keep the score, play sound effects, and build your first playable game.
  • Use more advanced C++ topics such as classes, inheritance, and references to spawn and control thousands of enemies, shoot with a rapid fire machine gun, and realize random scrolling game-worlds
  • Stretch your C++ knowledge beyond the beginner level and use concepts such as pointers, references, and the Standard Template Library to add features—for example, split-screen coop, immersive directional sound, and custom levels loaded from level-design files
  • Get ready to go and build your own unique games!
View Curriculum
  • This course offers a fun, example-driven approach to learning game development and C++. In addition to explaining game development techniques in an engaging style, the games are built in such a way that the key C++ topics are introduced in a practical (and not theory-based) way, with multiple runnable/playable stages in each section.

This video course is all about offering you a fun introduction to the world of game programming, C++, and the OpenGL-powered SFML using three fun, fully-playable games. These games are an addictive frantic two-button tapper, a multi-level zombie survival shooter, and a split-screen multiplayer puzzle-platformer.

We will start with the very basics of programming, such as variables, loops, and conditions, and you will become more skillful with each game as you move through the key C++ topics, such as OOP (Object-Orientated Programming), C++ pointers, and an introduction to the Standard Template Library. While building these games, you will also learn exciting game programming concepts such as particle effects, directional sound (spatialization), OpenGL programmable Shaders, spawning thousands of objects, and more.

About The Author

John Horton is a coding and gaming enthusiast based in the UK. He has a passion for writing apps, games, books, and blog articles about programming, especially for beginners. He is the founder of Game Code School, which is dedicated to helping complete beginners start coding using the language and platform that are best for them. John sincerely believes that anyone can learn to code and that everybody has a game or an app inside them, and that they
just need to do enough work to bring it out. He has authored around a dozen technology books, most recently the following:

  • Beginning C++ Game Programming
  • Android Programming for Beginners
  • Android Game programming by Example
  • Java Building Android Games
Who is the target audience?
  • If any of the following describe you, this course is perfect for you:
  • You have no C++ programming knowledge whatsoever or need a beginner-level refresher course
  • You want to learn to build games or just use games as an engaging way to learn C++
  • You aspire to publish a game one day, perhaps on Steam
  • You just want to have loads of fun and impress friends with your creations
Compare to Other C Courses
Curriculum For This Course
64 Lectures
C++, SFML, Visual Studio, and Starting the First Game
10 Lectures 49:21

This video provides an overview of the entire course.

Preview 04:25

SFML has the potential to build the highest-quality 2D games. So a beginner can start using SFML and not worry about having to start again with a new language/library as their experience grows. Let's explore the games we will build using SFML.

The Games, C++, and SFML

Now that we know about how we will be making these games, it is time to set up a development environment. This video will show us how to proceed with that.

Setting Up the Development Environment

If we don't know how the game is going to work on the screen, how can we possibly make it work in code? Let's learn how to plan the game and create a new project from the reusable project template.

Planning Timber!!! and Creating a Project from the Template

Assets are things we need in order to make a game. It mainly includes font, sound and graphics. We must know how to add them. This video guides us with assets and understanding screen and internal co-ordinates.

Adding Project Assets and Understanding Co-ordinates

It's time to apply all that we've learned and start coding the game. This video will guide us with the initial code and explain what each line of code does.

Starting to Code the Game

We've studied about SFML but using SFML can be a bit tricky. Let's explore how we can use SFML features to open a new window.

Opening a Window using SFML

We need a way to stay in the program until the player wants to quit. Also, we must provide a way for the player to exit. Otherwise the game will go on forever. This video will help us achieve this goal.

The Main Game Loop

At last, we need to add some real graphics in our game. Let's see how we will create and draw the game background and display it.

Drawing the Game Background

There will always be problems and errors in every project you make, that is guaranteed. Let's learn about the types of errors so that we are able to identify and rectify them whenever they occur.

Handling Errors
Variables, Operators, and Decisions – Animating Sprites
7 Lectures 33:28

Variables are the way that our C++ games store and manipulate values. If we want to know how much health the player has then we need a variable. Is the game over or still playing? That's also a variable. So, let's first learn about variables before we proceed with our game.

Preview 06:01

At this point, we know exactly what variables are, the main types, and how to declare and initialize them, but we still can't do many operations with them. We need to manipulate our variables, add them, take them away, multiply, divide, and test them. Let's explore manipulating variables.

Manipulating Variables

In this video, we will add clouds, a tree and a bee to our game. This is going to be easy. We will use exactly the same procedure that we used in the previous section when we drew the background.

Adding Clouds, a Tree, and a Buzzing Bee

Random numbers are useful for a lot of reasons in games. Perhaps you could use them for determining what card the player is dealt with. This video will demonstrate using random numbers to determine the starting location and the speed of the bee and the clouds.

Random Numbers

The C++ if and else keywords are what enable us to make decisions. We have already seen if in action in the previous section when we detected, in each frame, whether the player had pressed the Esc key. So, it'd be quite easy to learn.

Making Decisions with if and else

Before we can move the bee and the clouds, we need to consider timing. As we already know, the main game loop executes over and over again, until the player presses the Esc key.


Let's use the elapsed time since the last frame, to breathe life into the bee and the clouds. This will solve the problem of having a consistent frame rate across different PCs.

Moving the Clouds and the Bee
C++ Strings, SFML Time, Player Input, and HUD
4 Lectures 19:40

As we progress with this game over the next three sections, the code will obviously get longer and longer. So, now it seems like a good time to think ahead and add a little bit more structure into our code. We will add this structure to give us the ability to pause and restart the game.

Preview 03:41

In the previous section, we briefly mentioned strings and we learned that a string can hold alphanumeric data. We didn't look at declaring, initializing, or manipulating strings. So let's do that now and briefly discuss the Text and Font classes.

C++ Strings, SFML Text, and Font

Now we know enough about strings, SFML Text, and SFML Font to go about implementing the HUD. This video will show us how to add a score and a message to our game screen.

C++ Strings, SFML Text, and Font

As time is a crucial mechanic in the game, it is necessary to keep the player aware of it. It will give him a sense of urgency as the end of the game draws near, and a sense of accomplishment if he performs well enough to maintain or increase his remaining time.

Adding a Time Bar
Loops, Arrays, Switch, Enumerations, and Functions – Implementing Game Mechanics
6 Lectures 31:51

In programming, we often need to do the same thing more than once. The obvious example that we have seen so far is our game loop. There are a few different types of loop and we will look at the most commonly used

Preview 05:03

If a variable is a box in which we can store a value of a specific type, like int, float, or char, then we can think of an array as a whole row of boxes. Let's learn about arrays in detail so we know how to use them.


We have already seen if, which allows us to make a decision whether to execute a block of code based upon the result of its expression. Sometimes a decision in C++ can be made better in other ways. This video will demonstrate using switch.

Making Decisions with switch

An enumeration is a list of all the possible values in a logical collection. They make the code clearer and less error-prone. Let's learn how to use class enumerations.

Class enumerations

A function is a collection of variables, expressions, and control flow statements (loops and branches). In fact, any of the code we have learnt about in the course so far can be used in a function. Let's explore C++ functions in this video.

Getting Started with Functions

This last video of the section will guide us in using all the new C++ techniques to draw and move some branches on the tree.

Growing the Branches
Collisions, Sound, and End Conditions – Making the Game Playable
5 Lectures 19:39

As we now move closer to running the game. Let's add the code for the player's sprite, as well as a few more sprites and textures and then draw them.

Preview 03:11

As we now move closer to running the game. Let's add the code for the player's sprite, as well as a few more sprites and textures and then draw them.

Handling the Player's Input

Every game has to end badly, with either the player running out of time (which we have already handled) or getting squished by a branch. Let's see how to detect the player getting squished.

Handling Death

Every game has to end badly, with either the player running out of time (which we have already handled) or getting squished by a branch. Let's see how to detect the player getting squished.

Handling Death

Now that we've built the game, let's take a look at these suggested enhancements for Timber!!! project. This video will show what the enhanced version of our game look like.

Improving the Game and the Code
Object-Oriented Programming, Classes, and SFML Views
7 Lectures 01:04:39

Understand and start with our Zombie Arena game.

Preview 07:22

Manage, change, or update easily to with OOP.

Object-Oriented Programming

Player class benefits from knowing a few details about the overall environment the game is running in.

Building Player - The First Class

Ability to provide the player the ability to change and modify their character to an extent.

Controlling the Game Camera with SFML View

Start the game engine by using the updated code.

Starting the Zombie Arena Game Engine

Manage the code to reduce its length and make it concise.

Managing the Code Files

In this video, we will learn how to manage the code for game.

Starting Coding the Main Game Loop
C ++ References, Sprite Sheets, and Vertex Arrays
4 Lectures 25:38

What do we do if we need to work on a number of complex objects which are needed in the main function? References are the solution to this problem.

Preview 06:37

SFML allows us to load a sprite sheet as a regular texture in exactly the same way we do for every texture. So, let's see how to do it.

SFML Vertex Arrays and Sprite Sheets

Now that we have our hands on with C++ References and we are capable of creating Sprite sheets, let us step ahead and learn to generate a scrolling background.

Creating a Randomly Generated Scrolling Background

By the end of this video you will be able to use and render the background. So, let's jump right in.

Using the Background
Pointers, the Standard Template Library, and Texture Management
7 Lectures 54:26

Pointers are variables that hold memory addresses. Typically, a pointer will hold the memory address of another variable. This sounds a bit like a reference but in this video, we will see how they are much more powerful.

Preview 09:29

Now that we have learned the basics about pointers. We will use a pointer to handle an ever-expanding horde of zombies.

Working with Pointers

The STL is a collection of data containers and ways to manipulate the data we put in those containers. Or to be more specific, it is a way to store and manipulate different types of C++ variables and classes. Let's learn more about STL in this video.

The Standard Template Library

Thousands of zombies represent a new challenge. Not only would loading, storing, and manipulating thousands of copies of three different zombie textures take up a lot of memory, but also a lot of processing power too. This video will show us how to use the TextureHolder class to solve this problem.

The TextureHolder Class

We are now armed with the TextureHolder class to make sure that our zombie textures are easily available, as well as only loaded into the GPU once, we can look into building a whole horde of them.

Building a Horde of Zombies

Now we have a class to create a living, attacking, and killable zombie. This video will show us how to spawn a whole horde of them.

Creating a Horde and Bringing It Back to Life

Since we have our TextureHolder class, we might as well be consistent and use it to load all our textures. Let's make some very small alterations to the existing code that loads textures for the background sprite sheet and the player.

Using the TextureHolder Class for All Textures
Collision Detection, Pickups, and Bullets
6 Lectures 44:43

As of now, we have a controllable character running around in an arena full of zombies that chase him. The problem is that they don't interact with each other. We need to detect collisions between the zombies and the player and give him bullets to defend himself.

Preview 11:02

Now that we've given the player bullets, we need to make them usable. This video will show us how to get the bullets working.

Making the Bullets Fly

The player would see a mouse cursor on the screen, at this moment. We have to replace it with a crosshair which gives him an aim to shoot on and looks cool as well. Adding a crosshair is easy and only requires one new concept. We'll see that in this video.

Giving the Player a Cross-Hair

In this video, we will code a Pickup class that has a Sprite, member as well as other member data and functions. We will add pickups to our game in just a few steps.

Coding a Class for Pickups

In this video, we will code a Pickup class that has a Sprite, member as well as other member data and functions. We will add pickups to our game in just a few steps.

Using the Pickup Class

We need to know when certain objects from our game touch certain other objects. We can then respond to that event in an appropriate manner. In our classes, we have already added functions to call when our objects collide. So, let's see how we'll detect collisions.

Detecting Collisions
Layering Views and Implementing the HUD
3 Lectures 10:33

Familiarize yourself with the details added to the code, especially the variable names.

Preview 04:26

Familiarize yourself with the details added to the code, especially the variable names.

Updating the HUD Each Frame

HUD stays neatly positioned over the top of the main game action after drawing it.

Drawing the HUD, and the Home, and Level-Up Screens
1 More Section
About the Instructor
Packt Publishing
3.9 Average rating
8,274 Reviews
59,218 Students
687 Courses
Tech Knowledge in Motion

Packt has been committed to developer learning since 2004. A lot has changed in software since then - but Packt has remained responsive to these changes, continuing to look forward at the trends and tools defining the way we work and live. And how to put them to work.

With an extensive library of content - more than 4000 books and video courses -Packt's mission is to help developers stay relevant in a rapidly changing world. From new web frameworks and programming languages, to cutting edge data analytics, and DevOps, Packt takes software professionals in every field to what's important to them now.

From skills that will help you to develop and future proof your career to immediate solutions to every day tech challenges, Packt is a go-to resource to make you a better, smarter developer.

Packt Udemy courses continue this tradition, bringing you comprehensive yet concise video courses straight from the experts.