Chapter 11: Creating XNA Shooter


Overview

In this chapter I want to guide you through the creation of XNA Shooter, a little shoot-’em-up game, which is actually quite fun to play. It looks and feels better than the usual boring arcade games thanks to many cool effects, nice looking 3D models and a 3D landscape in the background with houses and plants, real-time shadow mapping, a cool sound track, and nice sound effects. I did not really expect to get such a great game out of it when I started programming XNA Shooter (as you can probably guess from the name, which is not that great). But after I added shadow mapping, which is also used in the racing game in the last part of this book, the background and the 3D buildings looked very nice. The nice UI from the previous chapter and some cool post-screen shaders (see Chapter 8) also help.

This chapter allows you to follow every step that was made to create XNA Shooter. The basic game was coded in two to three days and only some of the more advanced classes like the EffectManager and the shadow mapping needed some additional tweaking. Shadow mapping is one of those things that is not only hard to implement at first, but you can spend days or even weeks tweaking it over and over again to make it look a little better and fix some issues (and there are always issues). XNA Shooter is completely based on the XnaGraphicEngine from Chapter 5 and on Rocket Commander XNA from Chapter 8. Only in this way is it even possible to create such a good looking game in that short timeframe.

It was not so much work to create the 3D models because I already had most of them from older projects. Thanks to the simple camera, which is fixed and always looks down on the ground, some 3D classes like rendering sky cube maps or lens flares could be ignored. The camera also simplifies the way you can do the shadow mapping because you always see about the same 3D area in size.

The game logic itself is handled in four classes:

  • The Player class, which you already know from the Rocket Commander game. It is even simpler here because you only need to keep track of the current time, score, health, and weapons.

  • The Unit class handles all enemy units; it updates their positions and AI and renders them on the screen.

  • The Projectiles class is used to keep track of all the weapon projectiles you or any enemy unit shoot out. This includes plasma balls, your rockets, fireballs, or enemy rockets. Instant weapons like the MG or Gatling-gun do not have projectiles; they hit the target immediately and you see the effects directly on the screen.

  • And finally the Item class is used to drop items after killing transporter or rocket frigate ships and allowing the player to pick them up by flying over them. Items can be health, EMP bombs, or simply one of the four weapon types.

The game logic is a little bit more complex than for the Rocket Commander game, but after you go through all these classes you can see that the code in the Mission class is really easy and after you put everything together the game is almost complete. Just a little bit of play testing and fixing bugs and the game is good to go.




Professional XNA Game Programming
Professional XNA Programming: Building Games for Xbox 360 and Windows with XNA Game Studio 2.0
ISBN: 0470261285
EAN: 2147483647
Year: 2007
Pages: 138

Similar book on Amazon
XNA Game Studio 4.0 Programming: Developing for Windows Phone 7 and Xbox 360 (Developer's Library)
XNA Game Studio 4.0 Programming: Developing for Windows Phone 7 and Xbox 360 (Developer's Library)
Learning XNA 3.0: XNA 3.0 Game Development for the PC, Xbox 360, and Zune
Learning XNA 3.0: XNA 3.0 Game Development for the PC, Xbox 360, and Zune
Beginning XNA 2.0 Game Programming: From Novice to Professional (Expert's Voice in Game Programming)
Beginning XNA 2.0 Game Programming: From Novice to Professional (Expert's Voice in Game Programming)
Microsoftu00ae XNAu00ae Game Studio 3.0: Learn Programming Now! (Pro - Developer)
Microsoftu00ae XNAu00ae Game Studio 3.0: Learn Programming Now! (Pro - Developer)

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net