XNA Creators Club Online

beginner's guide

2D Lessons

1 Introducing the 2D Tutorial
2 Creating the Game Project
3 Adding Assets
4 Drawing the Background
5 Creating a Cannon
6 Firing Cannonballs
7 Adding Enemies
8 Destroying Enemies
9 Keeping Score
x Extra Credit - Community Tutorials

7. Adding Enemies

Use a random number generator and a bit of math to create enemy UFOs that appear in random locations and fly across the screen.

Step 1

Watch Video
Create and initialize an array of enemy GameObjects, and declare constants to use when randomly placing the enemies.

Step 2

Watch Video
Create an UpdateEnemies method that moves enemies across the screen and "kills" enemies that leave the screen.

Step 3

Watch Video
Add on to the UpdateEnemies method to regenerate enemies that have died, placing them randomly on the screen.
More Details

Step 4

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