Beginning C++ Game Programming

Learn C++ from scratch and get started building your very own games

Beginning C++ Game Programming

John Horton

13 customer reviews
Learn C++ from scratch and get started building your very own games
Mapt Subscription
FREE
$29.99/m after trial
eBook
$28.00
RRP $39.99
Save 29%
Print + eBook
$49.99
RRP $49.99
What do I get with a Mapt Pro subscription?
  • Unlimited access to all Packt’s 5,000+ eBooks and Videos
  • Early Access content, Progress Tracking, and Assessments
  • 1 Free eBook or Video to download and keep every month after trial
What do I get with an eBook?
  • Download this book in EPUB, PDF, MOBI formats
  • DRM FREE - read and interact with your content when you want, where you want, and how you want
  • Access this title in the Mapt reader
What do I get with Print & eBook?
  • Get a paperback copy of the book delivered to you
  • Download this book in EPUB, PDF, MOBI formats
  • DRM FREE - read and interact with your content when you want, where you want, and how you want
  • Access this title in the Mapt reader
What do I get with a Video?
  • Download this Video course in MP4 format
  • DRM FREE - read and interact with your content when you want, where you want, and how you want
  • Access this title in the Mapt reader
$0.00
$28.00
$49.99
$29.99p/m after trial
RRP $39.99
RRP $49.99
Subscription
eBook
Print + eBook
Start 30 Day Trial
Subscribe and access every Packt eBook & Video.
 
  • 5,000+ eBooks & Videos
  • 50+ New titles a month
  • 1 Free eBook/Video to keep every month
Start Free Trial
 
Preview in Mapt

Book Details

ISBN 139781786466198
Paperback520 pages

Book Description

This book 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 like particle effects, directional sound (spatialization), OpenGL programmable Shaders, spawning thousands of objects, and more.

Table of Contents

Chapter 1: C++, SFML, Visual Studio, and Starting the First Game
The games
Meet C++
Microsoft Visual Studio
SFML
Setting up the development environment
Planning Timber!!!
Creating a project from the template
Project assets
Understanding screen and internal coordinates
Starting to code the game
Opening a window using SFML
The main game loop
Drawing the game background
Handling errors
FAQ
Summary
Chapter 2: Variables, Operators, and Decisions – Animating Sprites
C++ variables
Manipulating variables
Adding clouds, a tree, and a buzzing bee
Random numbers
Making decisions with if and else
Timing
Moving the clouds and the bee
FAQ
Summary
Chapter 3: C++ Strings, SFML Time, Player Input, and HUD
Pausing and restarting the game
C++ strings
SFML Text and Font
Adding a score and a message
Adding a time bar
FAQ
Summary
Chapter 4: Loops, Arrays, Switch, Enumerations, and Functions – Implementing Game Mechanics
Loops
Arrays
Making decisions with switch
Class enumerations
Getting started with functions
Growing the branches
FAQ
Summary
Chapter 5: Collisions, Sound, and End Conditions – Making the Game Playable
Preparing the player (and other sprites)
Drawing the player and other sprites
Handling the player's input
Handling death
Simple sound FX
Improving the game and the code
FAQ
Summary
Chapter 6: Object-Oriented Programming, Classes, and SFML Views
Planning and starting the Zombie Arena game
OOP
Building the Player-the first class
Controlling the game camera with SFML View
Starting the Zombie Arena game engine
Managing the code files
Starting coding the main game loop
FAQ
Summary
Chapter 7: C++ References, Sprite Sheets, and Vertex Arrays
C++ References
SFML vertex arrays and sprite sheets
Creating a randomly generated scrolling background
Using the background
FAQ
Summary
Chapter 8: Pointers, the Standard Template Library, and Texture Management
Pointers
The Standard Template Library
The TextureHolder Class
Building a horde of zombies
Using the TextureHolder class for all textures
FAQ
Summary
Chapter 9: Collision Detection, Pickups, and Bullets
Coding the Bullet class
Making the bullets fly
Giving the player a crosshair
Coding a class for pickups
Using the Pickup class
Detecting collisions
FAQ
Summary
Chapter 10: Layering Views and Implementing the HUD
Adding all the Text and HUD objects
Updating the HUD each frame
Drawing the HUD, and the home and level up screens
FAQ
Summary
Chapter 11: Sound Effects, File I/O, and Finishing the Game
Saving and loading the high-score
Preparing sound effects
Leveling up
Restarting the game
Playing the rest of the sounds
FAQ
Summary
Chapter 12: Abstraction and Code Management – Making Better Use of OOP
The Thomas Was Late game
Structuring the Thomas Was Late code
Building the game engine
Coding the main function
FAQ
Summary
Chapter 13: Advanced OOP – Inheritance and Polymorphism
Inheritance
Polymorphism
Abstract classes - virtual and pure virtual functions
Building the PlayableCharacter class
Building the Thomas and Bob classes
Updating the game engine to use Thomas and Bob
FAQ
Summary
Chapter 14: Building Playable Levels and Collision Detection
Designing some levels
Building the LevelManager class
Coding the loadLevel function
Updating the engine
Collision detection
Summary
Chapter 15: Sound Spatialization and HUD
What is Spatialization?
How SFML handles spatialization
Building the SoundManager class
Adding SoundManager to the game engine
Populating the sound emitters
Playing sounds
The HUD class
Using the HUD class
Summary
Chapter 16: Extending SFML Classes, Particle Systems, and Shaders
The SFML Drawable class
Building a particle system
OpenGL, shaders, and GLSL
Summary
Chapter 17: Before you go...
Thanks!

What You Will 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 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 like split-screen coop, immersive directional sound, and custom levels loaded from level-design files
  • Get ready to go and build your own unique games!

Authors

Table of Contents

Chapter 1: C++, SFML, Visual Studio, and Starting the First Game
The games
Meet C++
Microsoft Visual Studio
SFML
Setting up the development environment
Planning Timber!!!
Creating a project from the template
Project assets
Understanding screen and internal coordinates
Starting to code the game
Opening a window using SFML
The main game loop
Drawing the game background
Handling errors
FAQ
Summary
Chapter 2: Variables, Operators, and Decisions – Animating Sprites
C++ variables
Manipulating variables
Adding clouds, a tree, and a buzzing bee
Random numbers
Making decisions with if and else
Timing
Moving the clouds and the bee
FAQ
Summary
Chapter 3: C++ Strings, SFML Time, Player Input, and HUD
Pausing and restarting the game
C++ strings
SFML Text and Font
Adding a score and a message
Adding a time bar
FAQ
Summary
Chapter 4: Loops, Arrays, Switch, Enumerations, and Functions – Implementing Game Mechanics
Loops
Arrays
Making decisions with switch
Class enumerations
Getting started with functions
Growing the branches
FAQ
Summary
Chapter 5: Collisions, Sound, and End Conditions – Making the Game Playable
Preparing the player (and other sprites)
Drawing the player and other sprites
Handling the player's input
Handling death
Simple sound FX
Improving the game and the code
FAQ
Summary
Chapter 6: Object-Oriented Programming, Classes, and SFML Views
Planning and starting the Zombie Arena game
OOP
Building the Player-the first class
Controlling the game camera with SFML View
Starting the Zombie Arena game engine
Managing the code files
Starting coding the main game loop
FAQ
Summary
Chapter 7: C++ References, Sprite Sheets, and Vertex Arrays
C++ References
SFML vertex arrays and sprite sheets
Creating a randomly generated scrolling background
Using the background
FAQ
Summary
Chapter 8: Pointers, the Standard Template Library, and Texture Management
Pointers
The Standard Template Library
The TextureHolder Class
Building a horde of zombies
Using the TextureHolder class for all textures
FAQ
Summary
Chapter 9: Collision Detection, Pickups, and Bullets
Coding the Bullet class
Making the bullets fly
Giving the player a crosshair
Coding a class for pickups
Using the Pickup class
Detecting collisions
FAQ
Summary
Chapter 10: Layering Views and Implementing the HUD
Adding all the Text and HUD objects
Updating the HUD each frame
Drawing the HUD, and the home and level up screens
FAQ
Summary
Chapter 11: Sound Effects, File I/O, and Finishing the Game
Saving and loading the high-score
Preparing sound effects
Leveling up
Restarting the game
Playing the rest of the sounds
FAQ
Summary
Chapter 12: Abstraction and Code Management – Making Better Use of OOP
The Thomas Was Late game
Structuring the Thomas Was Late code
Building the game engine
Coding the main function
FAQ
Summary
Chapter 13: Advanced OOP – Inheritance and Polymorphism
Inheritance
Polymorphism
Abstract classes - virtual and pure virtual functions
Building the PlayableCharacter class
Building the Thomas and Bob classes
Updating the game engine to use Thomas and Bob
FAQ
Summary
Chapter 14: Building Playable Levels and Collision Detection
Designing some levels
Building the LevelManager class
Coding the loadLevel function
Updating the engine
Collision detection
Summary
Chapter 15: Sound Spatialization and HUD
What is Spatialization?
How SFML handles spatialization
Building the SoundManager class
Adding SoundManager to the game engine
Populating the sound emitters
Playing sounds
The HUD class
Using the HUD class
Summary
Chapter 16: Extending SFML Classes, Particle Systems, and Shaders
The SFML Drawable class
Building a particle system
OpenGL, shaders, and GLSL
Summary
Chapter 17: Before you go...
Thanks!

Book Details

ISBN 139781786466198
Paperback520 pages
Read More
From 13 reviews

Read More Reviews

Recommended for You

Procedural Content Generation for C++ Game Development Book Cover
Procedural Content Generation for C++ Game Development
$ 39.99
$ 28.00
Learning C++ by Creating Games with UE4 Book Cover
Learning C++ by Creating Games with UE4
$ 26.99
$ 18.90
C++ Game Development Cookbook Book Cover
C++ Game Development Cookbook
$ 35.99
$ 25.20
SFML Game Development By Example Book Cover
SFML Game Development By Example
$ 39.99
$ 28.00
Android Programming for Beginners Book Cover
Android Programming for Beginners
$ 39.99
$ 28.00
Procedural Content Generation for Unity Game Development Book Cover
Procedural Content Generation for Unity Game Development
$ 39.99
$ 28.00