Click here to Skip to main content
6,822,613 members and growing! (15,848 online)
Email Password   helpLost your password?
Multimedia » DirectX » Games     Intermediate

Invasion - A computer game using DirectDraw

By Mauricio Ritter

This "Space Invaders"-like game was originally writen in DirectX 6, but I've changed some things so that you can use it with the latest version of the DirecX SDK. It uses just the Windows API and DirectX library (no MFC here). Have fun!
VC6, VC7Win2K, WinXP, DirectX, Dev
Posted:5 Jan 2002
Updated:4 Jun 2002
Views:246,383
Bookmarked:66 times
printPrint   add Share
      Discuss Discuss   Broken Article?Report  
64 votes for this article.
Popularity: 8.56 Rating: 4.74 out of 5

1
1 vote, 3.6%
2
2 votes, 7.1%
3
4 votes, 14.3%
4
21 votes, 75.0%
5

Sample Image - Invasion1.jpg Sample Image - Invasion2.jpg

This was my first attempt writing a computer game using the DirectX library. It was originally written for DirectX 6 library, but I've made some changes that made it work with the latest SDK. The code is based on the Windows API, without any reference to the MFC library. The only thing you need to compile this is VC++ and DirectX SDK, which can be found at http://www.microsoft.com/directx.

All the processing is done when no messages are available in the application message queue, by calling the UpdateFrame() function. As you see in the code, I haven't used many classes, and almost all the code is based on function calls. The only classes that are available are:

Alpha: this class is used as a reference to draw characters to the screen. This allow us to use a bitmap to draw the letters to the screen (so that the user doesn't need to install extra fonts in the system).

Extra: Defines an "Extra" element in the screen, that can be an Ammo box, an Bonus Box, a Weapon Advance Box or a Shield Charge.

Ovni: This class represents the UFOs that are going to be shot! Just to explain the name of the class... Ovni means UFO in Portuguese. Since I'm a Brazilian and a Portuguese speaker, there are some things in the code that are with my local language (don't worry, the comments are all English :o) )

Bullet: This represents the bullets that fly around the galactic battlefield.

Each one of the classes has a 'built-in' linked list that will be used a lot in the code. Each one of the classes have a common Draw function the is used to draw the specific object on the screen in its current state.

Almost everything in the code is commented, but if you have any trouble just mail me.

Have fun!

Updates

4 June 2002: I�ve removed a memory leak (directdraw interface was not being released) and have improved the surface creation function (winmain.cpp, line 3190). Now I try to create every surface on VIDEOMEMORY. If the function returns a DDERR_OUTOFMEMORY, I try to recreate it on SYSTEMMEMORY (winmain.cpp, line 3242).

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

About the Author

Mauricio Ritter


Member
Mauricio Ritter lives in Brazil, in the city of Porto Alegre. He is working with software development for about 8 years, and most of his work was done at a bank, within a home and office banking system.
Mauricio also holds MCSD, MCSE, MCDBA, MCAD and MCT Microsoft certifications and work as a trainer/consultant in some MS CTEC in his city.
Mauricio also works in his own programming site, aimed to Brazilian Developers: http://www.dotnetmaniacs.com.br

In his spare time he studys korean language...
Occupation: Web Developer
Location: Brazil Brazil

Other popular DirectX articles:

Article Top
You must Sign In to use this message board.
FAQ FAQ 
 
Noise Tolerance  Layout  Per page   
 Msgs 1 to 25 of 84 (Total in Forum: 84) (Refresh)FirstPrevNext
General3 Errors Pinmemberlangmain674896:45 17 Feb '07  
GeneralRe: 3 Errors PinmemberMauricio Ritter0:40 20 Feb '07  
GeneralVery helpful! PinmemberTHE SENSE20:26 5 Jan '07  
GeneralChanging Resolution PinmemberChrisian_leva16:51 3 Dec '05  
GeneralRe: Changing Resolution PinmemberSteve Maier6:52 24 Apr '06  
Generalcan you explain every method? Pinmemberwinile884815:58 12 Nov '05  
GeneralHow did you make your image tile sheet. PinmemberGerald McKoy9:05 12 Aug '05  
Generalhelp diving into the code Pinmembersergio_juma_nehama1:45 9 Dec '04  
GeneralHi Mauricio Pinmemberpushkar_0022:28 7 May '04  
GeneralRe: Hi Mauricio PinmemberMauricio Ritter11:33 8 May '04  
GeneralGREAT GAME!! PinmemberRyan McDermott8:21 18 Mar '04  
General2 Errors buggin the hell outta me! PinmemberDeSiPiMp6:47 15 Mar '03  
GeneralRe: 2 Errors buggin the hell outta me! PinmemberMauricio Ritter5:31 17 Mar '03  
GeneralGraphics PinmemberMario Bros.3:33 23 Feb '03  
GeneralRe: Graphics PinmemberMauricio Ritter9:06 23 Feb '03  
GeneralDirectDrawPalette Pinmembermehendru1:39 13 Dec '02  
General109 ERRORS! PinmemberDeSiPiMp8:16 11 Dec '02  
GeneralRe: 109 ERRORS! PinmemberDeSiPiMp9:33 11 Dec '02  
GeneralRe: 109 ERRORS! PinmemberMauricio Ritter4:31 12 Dec '02  
GeneralRe: 109 ERRORS! PinmemberDeSiPiMp8:25 12 Dec '02  
GeneralRe: 109 ERRORS! PinmemberMauricio Ritter8:47 12 Dec '02  
GeneralCould you also post the old version? PinsussAnonymous4:11 13 Nov '02  
GeneralRe: Could you also post the old version? PinmemberMauricio Ritter4:34 13 Nov '02  
GeneralVery Damn Cool PineditorBrian Delahunty8:27 1 Sep '02  
GeneralRequest PinmemberRama Krishna10:47 9 Jun '02  

General General    News News    Question Question    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

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

PermaLink | Privacy | Terms of Use
Last Updated: 4 Jun 2002
Editor: Chris Maunder
Copyright 2002 by Mauricio Ritter
Everything else Copyright © CodeProject, 1999-2010
Web21 | Advertise on the Code Project