Click here to Skip to main content
15,879,490 members
Articles / Desktop Programming / MFC

Star Fighter

Rate me:
Please Sign up or sign in to vote.
3.06/5 (27 votes)
25 Oct 20031 min read 97.9K   3.1K   30   11
A quick and dirty example to make a Star Fighter game using forms with C#

Sample Image - starfighter2.jpg

Introduction

There aren't really too many game programming examples with the C# language...not yet. Coming from a game programming background, I decided to whip one up with Visual Studio .NET. The final result after 2 hours of coding: Star Fighter 1.0.

Method

Instead of digging deep into the DirectX interface, I decided to just use simple Windows Forms. The process is quite simple. The entire game loop is handled by a simple form timer event which processes the ship movement, aliens movement, bombs, and bullets. Keyboard input is done by the keydown handler event. The entire code is self explanatory and fairly documented. Graphics were ripped from Blitz3d's demo game "Insectoids".

Bugs

Just a warning to everyone, Windows Forms is not the best method for intense action graphics, and if you experience some poor performance and slowdowns, it's normal. I ran this code using a P4 3.02 ghz and it went smoothly for me but others reported extreme slowness. Also, there's an annoying bug when the ship gets hit by the alien's bomb which causes the game to end - that which I could not figure out after a half an hour of debugging.

Questions, Comments, Complaints

For more projects, game demos, C# programming visit my website: http://www.3d-design.0catch.com/.

Have fun!

History

  • 26th October, 2003: Initial version

License

This article has no explicit license attached to it, but may contain usage terms in the article text or the download files themselves. If in doubt, please contact the author via the discussion board below.

A list of licenses authors might use can be found here.


Written By
United States United States
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
Generalgr8 Pin
shine ms15-Nov-07 2:48
shine ms15-Nov-07 2:48 
Generalipnee Pin
eraykaya16-Apr-07 19:04
eraykaya16-Apr-07 19:04 
QuestionTransparent PictureBox possible? Pin
grayaii22-Jan-04 9:42
grayaii22-Jan-04 9:42 
QuestionWhere's the article? Pin
Paul Evans6-Nov-03 0:46
Paul Evans6-Nov-03 0:46 
Hi,
There is a distinct lack of article for this. I'm going to hold of rating it incase you are actually going to add more to what you said.

Simply submitting source with no explanation isn't what Code Project is really about. Design decisions, why you did things the way you did, specific problems you came across and overcame, what you might do differently... that sort of thing.

Cheers,

Paul

/**********************************
Paul Evans, Dorset, UK.
Personal Homepage "EnjoySoftware" @
http://www.enjoysoftware.co.uk/
**********************************/

GeneralBomb Bug Pin
Steve Miller3-Nov-03 8:15
Steve Miller3-Nov-03 8:15 
GeneralRe: Bomb Bug Pin
snorkie16-May-07 10:22
professionalsnorkie16-May-07 10:22 
GeneralI know my demo sucks :-D Pin
Rikaino26-Oct-03 8:37
Rikaino26-Oct-03 8:37 
GeneralDo more with less Pin
Chris Richner26-Oct-03 6:01
Chris Richner26-Oct-03 6:01 
GeneralGameplay Pin
Giles26-Oct-03 4:13
Giles26-Oct-03 4:13 
GeneralManaged DirectX Pin
Heath Stewart26-Oct-03 2:11
protectorHeath Stewart26-Oct-03 2:11 
GeneralRe: Managed DirectX Pin
dog_spawn26-Oct-03 7:12
dog_spawn26-Oct-03 7:12 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.