Book Image

Beginning C++ Game Programming - Second Edition

By : John Horton
Book Image

Beginning C++ Game Programming - Second Edition

By: John Horton

Overview of this book

The second edition of Beginning C++ Game Programming is updated and improved to include the latest features of Visual Studio 2019, SFML, and modern C++ programming techniques. With this book, you’ll get a fun introduction to game programming by building five fully playable games of increasing complexity. You’ll learn to build clones of popular games such as Timberman, Pong, a Zombie survival shooter, a coop puzzle platformer and Space Invaders. The book starts by covering the basics of programming. You’ll study key C++ topics, such as object-oriented programming (OOP) and C++ pointers, and get acquainted with the Standard Template Library (STL). The book helps you learn about collision detection techniques and game physics by building a Pong game. As you build games, you’ll also learn exciting game programming concepts such as particle effects, directional sound (spatialization), OpenGL programmable shaders, spawning objects, and much more. Finally, you’ll explore game design patterns to enhance your C++ game programming skills. By the end of the book, you’ll have gained the knowledge you need to build your own games with exciting features from scratch
Table of Contents (25 chapters)
23
Chapter 23: Before You Go...

The project assets

Assets are anything you need to make your game. In our case, these assets include the following:

  • A font for the writing on the screen
  • Sound effects for different actions, such as chopping, dying, and running out of time
  • Graphics for the character, background, branches, and other game objects

All the graphics and sounds that are required for this game are included in the download bundle for this book. They can be found in the Chapter 1/graphics and Chapter 1/sound folders as appropriate.

The font that is required has not been supplied. This is because I wanted to avoid any possible ambiguity regarding the license. This will not cause a problem, though, as I will show you exactly where and how to choose and download fonts for yourself.

Although I will provide either the assets themselves or information on where to get them, you might like to create or acquire them for yourself.

Outsourcing the assets

There are a number of websites that allow you to contract artists, sound engineers, and even programmers. One of the biggest is Upwork (www.upwork.com). You can join this site for free and post your jobs. You will need to write a clear explanation of your requirements, as well as state how much you are prepared to pay. Then, you will probably get a good selection of contractors bidding to do the work. Be aware, however, that there are a lot of unqualified contractors whose work might be disappointing, but if you choose carefully, you will likely find a competent, enthusiastic, and great-value person or company to do the job.

Making your own sound FX

Sound effects can be downloaded for free from sites such as Freesound (www.freesound.org), but often the licence won’t allow you to use them if you are selling your game. Another option is to use an open source software called BFXR from www.bfxr.net, which can help you generate lots of different sound effects that are yours to keep and do with as you like.

Adding the assets to the project

Once you have decided which assets you will use, it is time to add them to the project. The following instructions will assume you are using all the assets that are supplied in this book’s download bundle. Where you are using your own, simply replace the appropriate sound or graphic file with your own, using exactly the same filename:

  1. Browse to the project folder, that is, D:\VS Projects\Timber.
  2. Create three new folders within this folder and name them graphics, sound, and fonts.
  3. From the download bundle, copy the entire contents of Chapter 1/graphics into the D:\VS Projects\Timber\graphics folder.
  4. From the download bundle, copy the entire contents of Chapter 1/sound into the D:\VS Projects\Timber\sound folder.
  5. Now, visit http://www.1001freefonts.com/komika_poster.font in your web browser and download the Komika Poster font.
  6. Extract the contents of the zipped download and add the KOMIKAP_.ttf file to the D:\VS Projects\Timber\fonts folder.

Let’s take a look at these assets – especially the graphics – so that we can visualize what is happening when we use them in our C++ code.

Exploring the assets

The graphical assets make up the parts of the scene that is our Timber!!! game. If you take a look at the graphical assets, it should be clear where in our game they will be used:

The sound files are all in .wav format. These files contain the sound effects that we will play at certain events throughout the game. They were all generated using BFXR and are as follows:

  • chop.wav: A sound that is a bit like an axe (a retro axe) chopping a tree
  • death.wav: A sound a bit like a retro “losing” sound
  • out_of_time.wav: A sound that plays when the player loses by running out of time, as opposed to being squashed

We have seen all the assets, including the graphics, so now we will have a short discussion related to the resolution of the screen and how we position the graphics on it.