We may earn an affiliate commission when you visit our partners.
Take this course
Packt Publishing

Are you looking to learn C++ from scratch and simultaneously build stunning and interactive games?

Explore this Learning Path and you'll get what you're looking for. Start as an amateur and rise as a pro by taking this Learning Path.

This Learning Path is a fun journey to the world of game programming starting from the very basics of C++ such as OOP, pointers, introduction to the Standard Template Library, and finally building OpenGL-powered SFML fully-playable complex games.

Read more

Are you looking to learn C++ from scratch and simultaneously build stunning and interactive games?

Explore this Learning Path and you'll get what you're looking for. Start as an amateur and rise as a pro by taking this Learning Path.

This Learning Path is a fun journey to the world of game programming starting from the very basics of C++ such as OOP, pointers, introduction to the Standard Template Library, and finally building OpenGL-powered SFML fully-playable complex games.

These games are an addictive frantic two-button tapper, a multi-level zombie survival shooter, and a split-screen multiplayer puzzle-platformer.

You will explore exciting game programming concepts such as particle effects, directional sound, OpenGL programmable Shaders, spawning thousands of objects, and more.

Packt’s Video Learning Paths are a series of individual video products put together in a logical and stepwise manner such that each video builds on the skills learned in the video before it.

Author:

John Horton

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 get started with coding using the language and platform that is best suited for them. John sincerely believes that anyone can learn to code and that everybody has a game or an app inside of them, and that they just need to do enough work to bring it out.

Enroll now

What's inside

Learning objectives

  • 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 co-op, immersive directional sound, and custom levels loaded from level-design files
  • Get ready to go and build your own unique games!

Syllabus

Beginning C++ Game Programming - Part 1

This video provides an overview of the entire course.

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.

Read more

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.

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.

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.

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.

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.

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.

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.

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.

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.

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.

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.

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.

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.

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.

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.

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.

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.

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.

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.

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.

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.

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.

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.

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.

Lots of different things depend on the movement of the player, such as when to show the axe, when to begin animating the log, and when to move all the branches down a place. This video shows us how to set up the keyboard handling for the player chopping.

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.

We've built the game but it has no sound yet. To complete the game, we will add three sounds. Each sound will be played on a particular game event. Let's identify what are the sounds and when we'll play them.

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.

Understand and start with our Zombie Arena game.

Manage, change, or update easily to with OOP.

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

Controlling the Game Camera with SFML View

Start the game engine by using the updated code.

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

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

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.

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.

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.

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

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.

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

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.

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.

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.

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.

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.

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.

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.

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.

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.

After all that hard work implementing the Pickup class, we can now go ahead and write code in the game engine to actually put some pickups into the game.

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.

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

Understand how to slow down our game loop.

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

Create and save the high score for each game.

Create sound effects to the game.

Enable the player to level-up.

Modify code and restart the game.

Play the sound and the final game.

To keep our game simple without losing the challenge, we will have the task of creating the need for two players to Play cooperatively. We also need to make sure the game is not too easy. This video shows us the basic features and the assets we need to create our game.

One of the problems that has been quite pronounced so far is how long and unwieldy the code gets. OOP allows us to break our projects up into logical and manageable chunks called classes. Let's see how we can make a big improvement to the manageability of the code.

As discussed earlier, we will code a class called Engine that will control and bind together the different parts of the Thomas Was Late game. This video guides you in building the Engine class, which will hold all other functions.

For instantiating the Engine class, we need a file that contains our main function and the code that instantiates the Engine class. Let’s see how we can do that.

We have seen how we can create objects from the classes of the SFML library. But, what if there is a class that has useful functionality, but is not quite what we want? This video will teach you how you can inherit from the other class.

Polymorphism allows us to write code that is less dependent on the types we are trying to manipulate. In this video, we'll take a look at what polymorphism means in its simplest form.

An abstract class is a class that cannot be instantiated and therefore cannot be made into an object. So, is it code that will never be used, then? Let's find out.

Now that we know the basics about inheritance, polymorphism, and pure virtual functions, we will put them to use. In this video, we'll build a PlayableCharacter class that has the vast majority of the functionality.

Now it's time for us to use inheritance for real. We will build a class for Thomas as well as Bob. They will both inherit from the PlayableCharacter class we have coded. Let's see how we do that.

In order to be able to run the game and see our new characters, we have to declare instances of them, call their spawn functions, update them in each frame, and draw them in each frame. Let's do that now.

There are different levels in a game. In this video, you will learn about the different levels in our game.

We need to add levels to the levelmanager class that we will create. This video will guide you through that.

For using the level manager class that we created earlier, we need to code for loading the level in the engine class.

After adding classes in engine, we will update the engine in order to make final changes in the view of our game in this video.

To detect if our players come in contact with other things in the game or each other, we need a collision detector.

Spatialization is making something relative to the space it is a part of. It gives the game a real-world feeling. In order to do that, we must first understand spatialization and how it works.

To manage all the sounds that will be used in our game, we will create a class and manage all our sound effects through that.

When a player nears a particular tile, a sound is emitted from the tile which makes it easy for the player to identify the type of tile they are going toward. This helps in creating a real-life effect in the game.

Now that we have all the functions for sound effects in the appropriate places, we will code for playing these sounds according to the time and place.

In order to interact with the player, we require text in our game. The HUD class helps in that.

To let the player know about his score, health, and even position, we need to know how to use the HUD class.

The Drawable class has just one function. It has no variables either. Furthermore, its one and only function is pure virtual. This means that if we inherit from Drawable, we must implement its one and only function. This video will guide you how we can solve this problem.

We will use the particle effect in our game. When a character Dies, he will explode in a starburst/firework-like particle effect. Let's see how we can achieve that.

Open Graphics Library is a programming library that handles 2D and 3D graphics. This video explores how OpenGL works.

Traffic lights

Read about what's good
what should give you pause
and possible dealbreakers
Uses SFML, which allows beginners to start building 2D games without needing to switch to a new language or library as their experience grows
Explores exciting game programming concepts such as particle effects, directional sound, and OpenGL programmable Shaders, which are useful for creating immersive gaming experiences
Taught by John Horton, the founder of Game Code School, which is dedicated to helping complete beginners get started with coding using the language and platform that is best suited for them
Requires knowledge of C++ to understand the Standard Template Library, which is a collection of data containers and ways to manipulate the data we put in those containers
Uses OpenGL, a programming library that handles 2D and 3D graphics, but does not explicitly state which version of OpenGL is used in the course

Save this course

Create your own learning path. Save this course to your list so you can find it easily later.
Save

Reviews summary

Learn c++ by building games

According to students, this learning path offers a largely positive experience for those looking to learn C++ through game development. The hands-on approach building playable games like Timber, Zombie Arena, and Thomas Was Late is frequently highlighted as a highly effective way to learn and apply concepts. Many found the instructor's explanations clear, guiding them from C++ basics to more advanced topics like pointers, STL, and game mechanics such as particle effects and collision detection. However, some students felt the pace of C++ fundamentals was a bit fast for complete newcomers, suggesting some prior programming knowledge might be beneficial. There were also mentions of minor technical challenges during the initial setup of libraries like SFML. Overall, it's seen as a solid and engaging introduction, particularly strong in demonstrating the practical application of C++ in game projects.
Instructor explains concepts clearly.
"John Horton explains C++ concepts clearly..."
"The lectures are easy to follow..."
"John is a great instructor."
Hands-on approach building games praised.
"This course is fantastic... The projects are fun and practical. I especially liked the Timber game section, it was a great start."
"Excellent learning path. The hands-on approach building three different games really solidified my understanding."
"Really enjoyed building the Zombie Arena game. The course shows you how to apply C++ concepts directly to game logic."
"The Thomas Was Late game project in Part 2 was a great challenge and learning experience."
Initial library setup can be tricky.
"...setting up SFML initially was a bit tricky."
"Found the setup process frustrating. The SFML version used seemed slightly different from the latest, causing minor issues."
"There were also mentions of minor technical challenges during the initial setup of libraries like SFML."
Pace can be challenging for total novices.
"I found some of the C++ explanations a bit fast if you have absolutely no prior programming experience."
"The later game projects get quite complex quickly. Good for reinforcing concepts but maybe not for a total newcomer."
"The C++ foundations felt rushed. Better for someone with some basic C++ knowledge already."

Activities

Be better prepared before your course. Deepen your understanding during and after it. Supplement your coursework and achieve mastery of the topics covered in Learning Path: C++ Game Programming with these activities:
Review C++ Fundamentals
Strengthen your understanding of C++ fundamentals to better grasp game programming concepts.
Show steps
  • Review basic syntax and data types.
  • Practice writing simple C++ programs.
  • Understand object-oriented programming principles.
Review 'SFML Game Development' book
Deepen your understanding of SFML, a key library used in the course, by studying a dedicated book.
Show steps
  • Read the book's introduction and overview of SFML.
  • Work through the examples provided in the book.
  • Experiment with different SFML features.
Implement basic game mechanics
Reinforce your understanding of game programming concepts by implementing basic mechanics like movement, collision detection, and scoring.
Show steps
  • Implement player movement using keyboard input.
  • Create a simple collision detection system.
  • Implement a basic scoring system.
Four other activities
Expand to see all activities and additional details
Show all seven activities
Create a simple game demo
Solidify your knowledge by creating a small game demo that incorporates the concepts learned in the course.
Show steps
  • Design a simple game concept.
  • Implement the core game mechanics.
  • Add basic graphics and sound effects.
  • Test and refine your game demo.
Contribute to an SFML project
Deepen your understanding of SFML and game development by contributing to an open-source project.
Show steps
  • Find an SFML-based open-source project.
  • Identify a bug or feature to work on.
  • Submit a pull request with your changes.
Review 'Game Programming Patterns' book
Learn about common design patterns used in game development to improve your code's structure and maintainability.
Show steps
  • Read the book's introduction and overview of design patterns.
  • Study the examples provided in the book.
  • Apply design patterns to your own game projects.
Develop a complete game
Apply your knowledge and skills by developing a complete game from scratch, incorporating advanced features and mechanics.
Show steps
  • Design a game concept with clear goals and mechanics.
  • Implement the game's core features and systems.
  • Add advanced features like AI, networking, or procedural generation.
  • Polish the game with high-quality graphics, sound, and user interface.
  • Test and refine the game based on feedback.

Career center

Learners who complete Learning Path: C++ Game Programming will develop knowledge and skills that may be useful to these careers:
Game Programmer
A game programmer uses their knowledge of programming languages and game development tools to create engaging and interactive games. This role involves writing code to implement game mechanics, artificial intelligence, and user interfaces. This course, with its focus on C++ and game development using SFML and OpenGL, helps build a strong foundation for someone wanting to become a game programmer. This course's hands on approach to game creation, from basic concepts to complex game mechanics, is particularly valuable for an aspiring game programmer.
Gameplay Programmer
A gameplay programmer is a specific type of game programmer who focuses on the interactive elements of a game. This includes character control, game mechanics, and implementing the designer's vision. This course's curriculum directly addresses gameplay programming, by teaching game mechanics in C++ and the SFML framework. The projects this course develops are directly relevant to the day to day work of a gameplay programmer. By building multiple complete game prototypes, this course assists learners in becoming a gameplay programmer.
Graphics Programmer
A graphics programmer specializes in developing the visual aspects of games and other computer graphics applications. They work with rendering engines, shaders, and other graphics libraries to create stunning visual effects. This course explores OpenGL programmable shaders, which are part of the daily toolkit for a graphics programmer. The course also provides a hands-on understanding of game development, which is a valuable asset for anyone seeking a position as a graphics programmer. The course's use of C++ directly aligns with industry standards for graphics programming.
Engine Programmer
An engine programmer works on the underlying technology that powers the game, including the rendering engine, physics engine, and other core systems. A course that covers game programming with C++, such as this one, allows a learner to gain a fundamental understanding of the game engine by building multiple games from scratch. This course directly addresses core C++ concepts, as well as aspects of the OpenGL graphics library, which are often used in game engine development. This course may be useful for an aspiring engine programmer.
User Interface Programmer
A user interface programmer creates the visual and interactive elements of software applications, including games. This role requires a strong understanding of programming and user interface design. This course may be useful for a user interface programmer, as the course provides hands-on experience using C++ to build game interfaces. This course provides insight into how user interfaces are created in games which could be valuable to a user interface programmer.
Tools Programmer
A tools programmer develops the software used by game developers to create game assets, levels, and other content. The course's exposure to game development using C++ is directly relevant to this position, as many game development tools are built using C++. This course builds a foundation in C++ programming, which is crucial for a tools programmer. This course may be useful for aspiring tools programmer.
Software Engineer
Software engineers design and develop software applications, often working in a team environment. This course provides a practical understanding of C++, a widely used language in software development. It also provides significant information about Object Oriented Programming. This course may be useful for a software engineer, as it explores core concepts of programming using the C++ language, and by working with projects that require problem solving. The course's focus on practical application makes it a solid choice for someone looking to become a software engineer.
Simulation Engineer
Simulation engineers develop and implement simulations for various industries, including aerospace, automotive, and gaming. A simulation engineer needs a strong understanding of programming principles, and the C++ language is frequently used in development for simulations. This course focuses on C++ programming within a game development context. Consequently, this course may be useful for an aspiring simulation engineer. The course focuses on the concepts of an engine, which is important for simulation work.
Mobile Game Developer
A mobile game developer designs and develops games for mobile platforms, such as iOS and Android. This course provides a valuable introduction to C++, which can be used to develop games for mobile platforms. This course helps a future mobile game developer to build a foundation in game development using industry standard tools and practices. This course may be useful to a mobile game developer.
Game Designer
Game designers are responsible for creating and implementing the vision for the game. They work closely with programmers to ensure the mechanics are implemented in a fun and engaging way. While this course is primarily focused on game programming using C++, it may be useful for a game designer, as it provides valuable insights into the technical aspects of game development and the capabilities of C++. This course builds a deeper understanding of programming concepts and how they are used in the context of game creation.
Artificial Intelligence Programmer
An artificial intelligence programmer develops the algorithms and logic that control non-player characters in games. They need a strong background in mathematics, programming, and artificial intelligence principles. This course provides practical experience using C++, which is a commonly used language in AI development. This course may be useful for an artificial intelligence programmer, since game programming naturally contains aspects of artificial intelligence, such as in how enemies move and react.
Research Scientist
Research scientists design and conduct research in a variety of fields, often requiring strong analytical and programming skills. A research scientist might need to write code for their experimental simulations which will be performed on a computer. This course provides valuable exposure to C++, which is often used in scientific computing. This course may be useful for a research scientist, as it allows a learner to build a familiarity with low level programming principles and data structures. An advanced degree such as a Master's or PhD is typically required for this role.
Level Designer
A level designer creates the environments and layouts within a game, and is responsible for crafting engaging play spaces. Although this course is not directly aimed at level design, it may be useful for a level designer, as the course provides exposure to game development using C++. This experience may be valuable to a level designer by building awareness of game engine constraints and capabilities. The course helps to build a more complete understanding of the game development process.
Computer Science Educator
A computer science educator teaches programming principles and computer science concepts at various educational levels. While this course isn't directly for educators, it may be useful for a computer science educator, this course provides a practical understanding of C++ and game development, which are useful when teaching the subject. The course's hands-on approach helps build a more complete understanding of the topic.
Sound Designer
A Sound Designer creates the audio elements that are used in games and other media, including sound effects, music, and dialogue. This course may be useful for a sound designer, as it contains information about the development of sound effects as used in video games. This course provides exposure to how sound effects are implemented into games using C++ and programming frameworks. The course helps to build a more complete understanding of game development.

Reading list

We've selected two books that we think will supplement your learning. Use these to develop background knowledge, enrich your coursework, and gain a deeper understanding of the topics covered in Learning Path: C++ Game Programming.
Provides a comprehensive guide to using SFML for game development. It covers topics such as graphics, audio, and networking, which are essential for building games. This book is particularly useful for understanding how SFML works and how to use it effectively. It serves as a valuable reference tool throughout the course.
Explores common design patterns used in game development. It provides practical solutions to recurring problems and helps you write more maintainable and efficient code. While not strictly necessary for the course, it offers valuable insights into software design principles. This book is more valuable as additional reading to expand your knowledge.

Share

Help others find this course page by sharing it with your friends and followers:

Similar courses

Similar courses are unavailable at this time. Please try again later.
Our mission

OpenCourser helps millions of learners each year. People visit us to learn workspace skills, ace their exams, and nurture their curiosity.

Our extensive catalog contains over 50,000 courses and twice as many books. Browse by search, by topic, or even by career interests. We'll match you to the right resources quickly.

Find this site helpful? Tell a friend about us.

Affiliate disclosure

We're supported by our community of learners. When you purchase or subscribe to courses and programs or purchase books, we may earn a commission from our partners.

Your purchases help us maintain our catalog and keep our servers humming without ads.

Thank you for supporting OpenCourser.

© 2016 - 2025 OpenCourser