Head First C#: Lab #3: Invaders

The contest to submit working code for this lab is now closed. Congratulations to Ray Folwell from Derby, UK! You can still send in creative alternatives, though—see these details.
Lab #3 Opening Image

The Grandfather of Video Games

Head First C#

In this lab you’ll pay homage to one of the most popular, revered and replicated icons in video game history, a game that needs no further introduction. It’s time to build Invaders.


Your mission: defend the planet against wave after wave of invaders

  • The invaders attack in waves, where each wave is a tight formation of 30 individual invaders. As the player destroys invaders, the score goes up. The bottom invaders are shaped like stars and worth 10 points. The spaceships are worth 20, the saucers are worth 30, the bugs are worth 40, and the satellites are worth 50. The player starts with three lives. If he loses all three lives or the invaders reach the bottom of the screen, the game’s over.

  • The invaders attack in waves of 30. The first wave moves slowly and fires a few shots at a time. The next wave moves faster, and fires more shots more frequently. If all 30 invaders in a wave are destroyed, the next wave attacks.

  • As the player destroys the invaders, the score goes up. It’s displayed in the upper left-hand corner.

  • The player starts out with three ships. The first ship is in play, and the other two are kept in reserve. His spare ships are shown in the upper right-hand corner.

  • The multicolored stars in the background twinkle on and off, but don’t affect gameplay at all.

  • The invaders return fire. If one of the shots hits the ship, the player loses a life. Once all lives are gone, or if the invaders reach the bottom of the screen, the game ends and a big “GAME OVER” is displayed in the middle of the screen. The player moves the ship left and right, and fires shots at the invaders. If a shot hits an invader, the invader is destroyed and the player’s score goes up.

You'll find the class diagrams, method declarations, architecture overview, and everything else you'll need to build Lab #3 in Head First C#.

Download the graphics you'll need here. (zip)

Download an installer for the finished lab.