O'Reilly logo

Learning XNA 4.0 by Aaron Reed

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Creating Power-Ups

We’ll add one last thing to the game in this chapter, and then it will be up to you to fine-tune and tweak it further. You have three sprites that don’t do anything at this point: the skull ball, the plus, and the bolt. These sprites are meant not to take away a player’s life when they collide with the player’s object, but rather to have some positive or negative effect on the player.

As in previous sections in this chapter, we’re really getting into the creative aspect of game development here, and if there’s something you feel would add a great deal of entertainment to the game, you should look at adding that functionality. As you consider implementing things like power-ups, there really is no limit to what you can do.

For the purposes of this book, the effects that these objects will have when they collide with the player object are as follows:

  • The bolt causes the player object to move at 200% of its current speed for 5 seconds.

  • The skull ball causes the player object to move at 50% of its current speed for 5 seconds.

  • The plus causes the player object to be 200% larger than its current size for 5 seconds.

Essentially, a power-up (or power-down, if the effect is negative to the player) will run for a given number of seconds, and then the effect will wear off. In this game, the effects will stack, meaning that you can be influenced by more than one effect at a given time, and you can be influenced by the same effect multiple times (for instance, if you hit two skull ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required