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

9. Creating Enemies

Use the random number generator and linear interpolation math to create regenerating enemy UFOs that fly across the screen.

Step 1

Watch Video
Instantiate a random number generator, and create and fill an enemy GameObject array to represent the enemy UFOs.

Step 2

Watch Video
Start an UpdateEnemies method that will move the enemy GameObjects across the screen by their velocity each frame.

Step 3

Watch Video
Create constants to constrain your random number generator, then modify the UpdateEnemies method to randomly place your enemies using random numbers and linear interpolation.

Step 4

Watch Video
Draw the enemy UFOs on screen using the DrawGameObject method.
Download source code
var gDomain='m.webtrends.com'; var gDcsId='dcschd84w10000w4lw9hcqmsz_8n3x'; var gTrackEvents=1; var gFpc='WT_FPC'; /*<\/scr"+"ipt>");} /*]]>*/
DCSIMG