Skip to main content
Email Password   helpLost your password?

Introduction

Space Invaders is one of the most famous arcades in the world, and many of us programmers developed our own version of this game in our favourite programming language. I decided to create a version using only WinForms objects, maintaining as many features as possible (primarily, the graphics).

ScreenShot

Background

At first, you must know that every label object has got its image property, which can be used as background for a text. Of course, if you set text to empty string, you see nothing but the image itself! So, I decided to use labels for player ship, for aliens and for bullets. For aliens movement, I placed all of them in a panel, so that I can shift the entire armada only by setting the top and left property of the panel. To be right, there are two panels and two armadas, which are shown alternately to change aliens' legs positions.

Using the Code

There is a class for each of the main actors of the game: bullets, invaders and ship. In the main form, a timer is used for checking the keyboard, and another timer for moving the actors. To handle keyboard input smoothly, I didn't use the KeyPress event, but I used GetAsyncKeyState from DDL user32; in this way, there is no delay between the first and second hit of the key.

Note: Use the left and right arrow keys for moving the ship, and space key for shooting.

History

You must Sign In to use this message board.
 
 
Per page   
 FirstPrevNext
GeneralYay (and bug) Pin
Chris Maunder
5:19 17 Jun '08  
GeneralRe: Yay (and bug) Pin
Jubjub
10:34 17 Jun '08  
GeneralRe: Yay (and bug) Pin
GCalcerano
21:26 17 Jun '08  
GeneralRe: Yay (and bug) Pin
Rich Leyshon
5:22 24 Jun '08  


Last Updated 17 Jun 2008 | Advertise | Privacy | Terms of Use | Copyright © CodeProject, 1999-2009