Missile Command using C# and .NET
By David Lambert
Source code: MissileCommand.zip 109 KB
Missile Command .NET is a simple video game written in C# using GDI+ for graphics. It's a tribute to the classic Missile Command game by Atari. I wrote this game to teach myself more about programming in C#.
What can you learn from this code?
This code demonstrates:
- How to use the System.Drawing namespace to render simple yet effective graphics.
- How to use the System.IO namespace to read from and write to text files.
- How to implement multiple forms and pass information between them.
- How to implement a window menu bar in code.
- How to use a Timer component to trigger an event at a regular interval.
- How to detect a collision between graphics using the Bitmap.GetPixel method.
- How to interact with various input controls on a form.
- How to pull good performance from a C# Windows application by eliminating boxing/unboxing ('new' keyword) from core code, avoiding implicit and explicit type conversions, and using the StringBuilder class to build strings instead of the '+' operator.
About the Author: David Lambert is a web developer with 7 years of professional IT experience and 1 year of experience in ASP.NET / C#. He's also author of Sarnik - The Zorion Chronicles, a DHTML roleplaying game at http://www.sarnikdhtml.com.