Click here to Skip to main content
12,243,058 members (47,797 online)
Click here to Skip to main content
Add your own
alternative version

Stats

56.8K views
2.5K downloads
26 bookmarked
Posted

SpaceWarrior - A 2D DirectDraw Game

, 21 Dec 2006 CPOL
Rate this:
Please Sign up or sign in to vote.
An article on a simple 2D space shooting game under DirectDraw.

SpaceWarrior screenshot

Introduction

Ever read/heard of the "Tricks of the Windows game programming gurus", a book by Andre Lamothe?

Well, having that book in my hands (or in my computer) allowed me to dive into the secrets and tricks of Windows game development. The author of this book decided to share his 20-year experience as a Windows game developer and a programmer.

In this book, he covers Windows GDI and DirectX (DirectDraw, DirectPlay, and DirectSound) fundamentals, and shows to the readers how to build fast and simple 2D game engines under DirectX.

Piece by piece, according to the book, I have built a DirectX wrapper library as a base part of a future full-featured 2D game engine.

Background

The background for my search for the ultimate game book I took some time ago can be found in the secret wish of any "real programmer" - we all want to build the game at last. And we want it to be good...

You will find a lot more information in the book regarding the following:

  • Win32 applications basics
  • COM and DirectX basics
  • Vector rasterization and 2D transformations
  • Force Feedback joysticks
  • Sounds and music
  • Algorithms, data structures, memory management, and multithreading
  • Computer AI basics
  • Physics basics

And this is just a part of the contents of the book! It covers a lot of ground, and it may take months to be understood, but still it must be used as a reminder of how something can be (and is being) done in the "world of game developers".

Using the code (if you can call it this way)

There are the DXEngine.h and DXEngine.cpp files that should be added to the Win32 project (not the MFC project). Also, the latest DirectX SDK does not support MS Visual Studio 6.0 any longer, so you must use the MS Visual Studio .NET environment.

Basically, it goes like this (but, don't laugh please):

DXEngine_Init();    // Loads DirectX modules

DXEngine_Render();    // Your game code

DXEngine_Deinit();    // Unloads DirectX modules

There is a number of DXEngine functions that you can use for:

  • Image loading (bitmaps)
  • Pixel drawing
  • Vector graphics drawing (lines, polygons)
  • Filling vector shapes (filled polygons)
  • Text drawing
  • 2D transformations (translation, rotation, scaling)

However, there is no sound support implemented yet! Why? I don't know... I didn't want it for now.

There is a lot of code you must write down yourself, but it is your game, right? Please, download the sample project and go through the source, it is the only way to understand the game development issue. I'm not kidding at all. There is no way to write an article that will teach you to be a game programmer.

And get the book as soon as possible (if you don't like my game), and write your own! It will be a good one for sure, I know.

Points of Interest

I have learned many interesting/fun/annoying things while I was writing the code, and I have seen clever/wild/zany things for the rest of my life. Kidding... I have just started to have fun!!!

Happy New Year, my friend...

History

In this release of the Space Warrior game I have added UFO enemies and another asteroid type.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

darkoman
Software Developer (Senior) Elektromehanika d.o.o. Nis
Serbia Serbia
He has a master degree in Computer Science at Faculty of Electronics in Nis (Serbia), and works as a C++/C# application developer for Windows platforms since 2001. He likes traveling, reading and meeting new people and cultures.

You may also be interested in...

Comments and Discussions

 
GeneralMissing Variable Errors Pin
armage225-Apr-08 5:22
memberarmage225-Apr-08 5:22 
Questionhow to use on vc++ 6 Pin
tedkidane29-May-07 6:08
membertedkidane29-May-07 6:08 
QuestionRepair?? Pin
descartes25-Jan-07 8:58
memberdescartes25-Jan-07 8:58 
AnswerRe: Repair?? Pin
darkoman25-Jan-07 21:24
memberdarkoman25-Jan-07 21:24 
GeneralHangs & Crashes Pin
Polymorpher10-Jan-07 14:52
memberPolymorpher10-Jan-07 14:52 
GeneralRe: Hangs & Crashes Pin
darkoman10-Jan-07 21:14
memberdarkoman10-Jan-07 21:14 
GeneralCode Dump Pin
Gokalp Peker19-Dec-06 5:04
memberGokalp Peker19-Dec-06 5:04 
GeneralRe: Code Dump Pin
darkoman19-Dec-06 5:20
memberdarkoman19-Dec-06 5:20 
GeneralRe: Code Dump Pin
Gokalp Peker19-Dec-06 20:52
memberGokalp Peker19-Dec-06 20:52 
GeneralRe: Code Dump Pin
darkoman19-Dec-06 21:58
memberdarkoman19-Dec-06 21:58 
GeneralRe: Code Dump Pin
Gokalp Peker19-Dec-06 22:10
memberGokalp Peker19-Dec-06 22:10 
GeneralRe: Code Dump Pin
darkoman19-Dec-06 22:40
memberdarkoman19-Dec-06 22:40 
GeneralRe: Code Dump Pin
Gokalp Peker19-Dec-06 23:40
memberGokalp Peker19-Dec-06 23:40 
GeneralRe: Code Dump Pin
darkoman19-Dec-06 23:53
memberdarkoman19-Dec-06 23:53 

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.

| Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.160426.1 | Last Updated 21 Dec 2006
Article Copyright 2006 by darkoman
Everything else Copyright © CodeProject, 1999-2016
Layout: fixed | fluid