Adding a Power-Up

You've done well here—you've built your first 3D game, complete with scoring and increasingly difficult levels, and packed with a ton of fun! Before we end this chapter, though, let's do one more thing. Not that games are boring, but anything that breaks up the monotony of regular gameplay goes a long way toward making a game even more exciting and addicting.

In this section, you'll add a power-up feature that will be awarded when a player gets three consecutive kills. The power-up will let the player shoot in a rapid-fire mode for 10 seconds. I know...that sounds really exciting, so let's get to it.

First, you'll want to add a sound effect that you'll play when the rapid-fire power-up is awarded. With the source code for this chapter, in the 3D Game\Content\Audio folder, you'll find a sound effect called RapidFire.wav. Copy that file to your project's Content\Audio directory in Windows Explorer. Remember not to add the file to your project in Visual Studio because you'll be adding it to your XACT project file.

Open your XACT project file from within XACT, add the RapidFire.wav sound to the wave bank, and create a sound cue for that sound. Then, save the XACT project file and close XACT (see Chapter 5 if you need more help editing an XACT project file).

In addition to including an audio sound effect when the player receives the power-up, it would be a good idea to include a text indicator. This will help alleviate any confusion as to why all of a sudden the player ...

Get Learning XNA 3.0 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.