www.NewsDownload.co.uk Page 8
Overview
Asteroids.dsw
Asteroids.dsp
Asteroids.def
Asteroids.rc
Asteroids.hpp
Asteriods.cpp
AstroShot.hpp
AstroShot.cpp
AstroShip.hpp
AstroShip.cpp
AstroRock.hpp
AstroRock.cpp
Astro_UFO.hpp
Astro_UFO.cpp
DirectDraw.lib
DirectDraw.dsw
DirectDraw.dsp
DirectDraw.hpp
DirectDraw.cpp
DirectSound.hpp
DirectSound.cpp
PolygonNumber.hpp
PolygonNumber.cpp
PolygonText.hpp
PolygonText.cpp
GNU License

Coding a DirectX Game

2012-04-11 18:30 By Jason Birch

Fourth in a series of how to code articles. Demonstrating coding an Asteroids Clone game with various technologies. This example using DirectX, implementing as a native Microsoft Windows game.

In this article I have converted my Asteroids Clone code into a Windows DirectX. I am now publishing the source code here under the GNU General Public License License as a series of articles describing how to write code using various technologies.

The code here can be freely distributed, but only on the condition that a credit to Jason Birch is maintained in the source code files and running application.

The source code is broken down into the classes which make the application, in the tabs on the left of this article. The tabs are placed in order from the simplest classes to the more complex classes last. There is a commentary accompanying each source code file explaining how the code operates.

The code for the DirectX version of this application has some additional features. Support for a two player game has been added, and simulates a cocktial style game where the display rotates 180 degees for player two, whom would be sitting on the opposite side of the cocktail table. The game also has an asteroid belt count down, during play when the countdown reaches zero, a belt of small asteroids appear. This is to prevent the player getting to the end of a level and then sitting and waiting for UFOs to get a high score. The game can also be paulsed using the Pause key.

The keys to play are:
5 - Add a game credit, 1 - Start one player game, 2 - Start two player game, Pause - Pause. A - About.
Player 1: Cursor left - Rotate left, Cursor right - Rotate right, Ctrl - Fire, Alt - Thrust, ' ' - Hyperspace.
Player 2: - Rotate left, - Rotate right, - Fire, - Thrust, - Hyperspace.

A compiled version of the game is available here, it is just 324KB in size.

Graphic and audio files can be downloaded here:
Asteroids.bmp Asteroids.ico Background.bmp
Belt.wav HyperSpace.wav Shot.wav UFO.wav
Credit.wav Rock.wav Thrust.wav UFOShot.wav


Screen Shot Of Two Player DirectX Conversion

Required Environment
To run a DirectX game, a Windows operating system is required.
To develop a DirectX game, Microsoft Visual Studio Express is required, which is freely available from www.microsoft.com.

Writing Code
Visual Studio is the best tool as it provides support for resources and good inline tools.

Compiling Code
Visual Studio is the best tool to compile the project.

Distributing Application
The application can only be run on a Microsoft Windows operating system. Copy the file onto the Windows desktop.

Running Application
The application is run by double clicking on the application icon.

Loading...