Beginning C++ Game Programming
上QQ阅读APP看书,第一时间看更新

Project assets

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

  • 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 sound required for the game are included in the download bundle. 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 licensing. 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 and acquire them for yourself.

Outsourcing assets

There are a number of websites that allow you to contract artists, sound engineers, and even programmers. One of the biggest is the www.upwork.com. You can join this site for free and post your jobs. You 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, there is 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 like www.freesound.org but often the license 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 as you like with.

Adding assets to the project

Once you have decided which assets you will use, it is time to add them to the project. These next instructions will assume you are using all the assets supplied in the 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 file name.

  1. Browse to the Visual D:\Visual Studio Stuff\Projects\Timber\Timber.
  2. Create three new folders within this folder and name them as graphics, sound, and fonts.
  3. From the download bundle, copy the entire contents of Chapter 1/graphics into the D:\Visual Studio Stuff\Projects\Timber\Timber\graphics folder.
  4. From the download bundle, copy the entire contents of Chapter 1/sound into the D:\Visual Studio Stuff\Projects\Timber\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:\Visual Studio Stuff\Projects\Timber\Timber\fonts folder.

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

Exploring assets

Graphical assets form the individual parts of the screen in our Timber!!! game. Take a look at the graphical assets and it should be clear where, in our game, they will be used.

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

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