XNA Creators Club Online

beginner's guide

3D Lessons

1 Introducing the 3D Tutorial
2 Creating the Game Project
3 Adding Assets
4 Drawing Terrain
5 Drawing a Game Object
6 Making a Missile Launcher
7 Firing Missiles
8 Making Sounds
9 Creating Enemies
10 Destroying Enemies

7. Firing Missiles

Create an array of missile objects that you can fire from your missile launcher by using your Xbox 360 controller or keyboard.

Step 1

Watch Video
Add new variables to your GameObject class to allow for objects that have velocity and that can toggle between alive and dead modes.

Step 2

Watch Video
Create and initialize an array of new missile GameObjects that can be fired by the player.

Step 3

Watch Video
Modify Update to call FireMissile when the player presses the appropriate button, but use previous input states to keep them from holding the button down.
More Details

Step 4

Watch Video
Learn about transformations and vectors in 3D while creating the FireMissile method that places missiles at the appropriate position and velocity when fired.

Step 5

Watch Video
Create an UpdateMissiles method that applies velocity to flying missiles and eliminates them from the game world when they fly too far away.

Step 6

Watch Video
Draw your missiles, using the DrawGameObject method in a loop.
Download source code
var gDomain='m.webtrends.com'; var gDcsId='dcschd84w10000w4lw9hcqmsz_8n3x'; var gTrackEvents=1; var gFpc='WT_FPC'; /*<\/scr"+"ipt>");} /*]]>*/
DCSIMG