Home > Games Programming, Programming > Space Defender : A Complete XNA Game by Ghoshehsoft

Space Defender : A Complete XNA Game by Ghoshehsoft

Space Defender

Update: Game updated to XNA GS4.0 , Download links added!

This was my first XNA game! It’s a cool 2D Game..
Unlike most space games, this game takes place in the atmosphere! not in the outer space 🙂
You have to defeat the invaders as they increase in number, you’ll also come across mother ships which are more advanced enemies that will chase you and fire energy pulses at you!. Play for some time and you’ll confront the Main Mother Ship…you think you’re up to it???

You have two weapons to stop your enemies : a rail gun that will fire small rapid bullets , and a missile launcher that fires missiles causing massive damage to your enemies!

The player can choose one of three Space Ships to play the game with… each space ship has it’s special ability : Rapid Fire, Turbo Ship, Heavy Armor…and if the player beats the game twice with two different ships, The ultimate ship will be unlocked!

You can play the game with your mouse ( I like to sit back and destroy the invaders just with my mouse 😀 ) OR with your keyboard
Instructions on how to play the game can be found under the How To Play window in the game.

Taking the repairs box is always a good idea!! a small white repairs box will show up from time to time! take it to regain health.

You can control the speed of your ship in the game, See How To Play for more instructions

Enough Talk! Let’s Play!

Download The Full Game Executable XNA 3.1

Download The Full Game Executable XNA 4.0

Full source code link at the bottom of the article

If you don’t have the XNA 3.1 SDK installed on your computer, you’ll have to install the XNA Redistributable 3.1, download it here for free.

If you like the game please let me know! my email is hisham.ghosheh@gmail.com

Some images of the game:

For XNA Developers:

Let’s talk a little about the game code & structure…
I programmed this game using XNA Game Studio 3.1 & C# 2008


Game Dialogs : since I couldn’t find XNA compatible classes to use for dialog boxes, I had to write my own, so I started with programming the Button class which almost simulates a Windows button.
Next comes the Label class , its main function is to display text after specifying the font,position… and it allows text wrapping which means you can specify the number of characters per line so your text might be displayed in more than one line…
There’s also the Animation class which is a picture box that displays an animation that can be used as a button! it’s a simple one though…

I used the former three classes to build some special dialog boxes..
I should have used Events to best manipulate the controls classes but I didn’t know much about Events handling back then 😦

In Game:

The main classes of the game are:
Sprite : which is an abstract class which all the ships,invaders inherit from , it’s a very common class..
Explosion : an explosion with properties such as radius,damage,duration,visible
Explosion Manager : This class the the only thing responsible for damaging ships/invaders… when a missile hits a ship it doesn’t damage it directly, it asks the explosion manager to create an explosion in the location of the impact , then each object in the game checks the explosion manager for near explosions to get damage from! even bullets/ships colliding with each other creates explosions…. writing this explosion manager has really made things easier for me! 🙂
Cloud : a simple class that represents a cloud with a size,speed and a position… the cloud will move automatically each time its Update method is called
Cloud Manager : a class the manipulates several clouds to give the effect of the cloudy sky, It creates clouds with random positions,sizes and speeds. I created two instances of this class, one is drawn behind the scene, the other is in front of it! which adds a really cool effect to the sky!
Enemy Manager : This class manipulates the enemies, it’s the one that spawns enemies of different types and updates,draws them. you can think of this class as a game level… the game is now a one level game but with some modifications this class can read a level from a file and send enemies according to the level

Collision Detection:

accurate collision detection is not much needed in this game so many ships has circles as their collision bounds others have a rectangle for collision

Sound :

I used XACT 3 it’s a really cool tool 🙂

Resources:

sprite sheets : found them on the internet…I don’t really remember where!
sounds : various sources and small games
backgrounds : Google Images 🙂

Other:

The game will automatically switch to full screen mode

Here you’ll find the full source code : a Visual Studio 2008 Solution, Have fun!

The code is well commented 🙂
You’re free to copy/modify any part of the code as long as you don’t claim the game for your self 🙂

Download Game Source Code (XNA 3.1 + VS2008)

Download Game Source Code (XNA 4.0 + VS2010)

Please note : source code was updated, if at compile time you receive an error saying “Unable to find manifest signing certificate in the certificate store” then please re-download the code or do the following : Project->Space Defender Properties->Signing->Create Test Certificate

Enter any password and the project should compile correctly!

Comments Are Always Welcome 🙂

Advertisements
  1. Gee
    26/06/2011 at 7:30 pm

    Thanks ^^

    • Fuchs
      27/06/2011 at 11:07 pm

      You’re welcome 🙂

  2. ralph
    10/01/2013 at 9:30 pm

    Screen shots look cool, the link for the source is broken, can you please repost?

    • Fuchs
      11/01/2013 at 5:47 am

      Mediafire.com doing it again! randomly blocking files in the name of “terms violation”!
      I updated the links to Dropbox links, thanks for notifying me :).

  3. Khaled Kokah
    05/10/2013 at 8:20 pm

    Dude you are amazing!! Thanks really!

    • Fuchs
      06/10/2013 at 10:14 am

      Thanks, I’m glad you liked it :).

  4. Davin
    07/06/2016 at 4:17 pm

    Hi Bro the link is not working to download this.

    • Fuchs
      07/06/2016 at 10:11 pm

      Which link of them? I’ve tried them all and they are working

  1. 23/11/2010 at 8:49 pm
  2. 11/02/2011 at 1:20 am
  3. 22/04/2011 at 12:02 am

What do you think?

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: