Theoretical Paper
- Computer Organization
- Data Structure
- Digital Electronics
- Object Oriented Programming
- Discrete Mathematics
- Graph Theory
- Operating Systems
- Software Engineering
- Computer Graphics
- Database Management System
- Operation Research
- Computer Networking
- Image Processing
- Internet Technologies
- Micro Processor
- E-Commerce & ERP
Practical Paper
Industrial Training
Bit Arrays
Bow & Arrow - DirectX
Need
The most thorny problem in MS-DOS game programming was hardware device support. Developers targeting PCs don't enjoy the same uniform platform that those developing for dedicated gaming consoles enjoy. The developers targeting game consoles drift to sleep each night knowing that the code they wrote that day will get a warm welcome from millions of identical machines - clones in a true sense of the word than any PC clone. The PC game developers toss and turn, dreaming about new graphics coprocessors, digital joysticks, 3D accelerators, and virtual-reality input devices. They know that their next game will be expected to support an even wider range of hardware devices than the ones they were struggling with that day. While nothing prevents individual games from taking advantage of hardware advances (and many have), it can be very difficult for the small, content-oriented game development shops to keep up. Their game no sooner hits the shelves than another wave of unsupported hardware possibilities rolls in. The lack of a consistent interface to these devices often requires developers to divert creative energy and development funds from the application itself to writing drivers that supports the new hardware features. Sadly, all this effort too often results in games that are difficult to install, frustrating customers and creating support costs that take huge bites out of the publisher's already thin profit margins.
A high-level operating system such as Windows has much to offer the game developer that can't be used to avoid many of the supports calls resulting from installation problems. For example, Plug and Play makes it simple to install the latest video board, input device, or sound card. The windows system registry can be consulted for configuration information during installation, and the Windows AutoPlay system is available to make that installation virtually automatic. Once the application is installed, it can call upon a vast repository of built-in device- independent functionality. Until now, however, using this platform has meant a severe performance penalty that was unacceptable to game developers.
All this changed when Microsoft created DirectX. DirectX offers the game developer the option of selecting a robust, well-documented platform on which to build a game or a multimedia application. DirectX opens the doors to Windows functionality without asking the developer to sacrifice performance and shifts the burden of hardware support back to the hardware manufacturers.
Overview
Here we want to explore the best API ever written for games development called DirectX. It provides hardware independence without compromising on speed and performance unlike GDI. Applications written using DirectX automatically take advantage of new hardware support without ever re-compiling.
Requirement
-
VC++ 6.0 Platform - for development
-
DirectX 6.0 or above
Preview
Steps To Develop This Application
-
Create a dialog-based application - 'Robin'.
-
Modify InitInstance( ) and remove the code that pops up the dialog. This is done only to get AppWizard support. The dialog classes can be removed from the project or left as it is.
-
Create a new class and derive it from 'A Generic CWnd'.
-
Create a full screen window without a title bar.
-
Obtain the IDirectDraw interface pointer using DirectDrawCreate( ).
-
Using IDirectDraw interface pointer obtain IDirectDraw2 interface pointer by calling QueryInterface( ). Next set the cooperative level and display mode suitably.
-
Using IDirectDraw2 interface pointer call CreateSurface( ) to create a primary surface and specify number of back buffers, in our case it is 1.
-
Using the surface pointer (IDirectDrawSurface returned by CreateSurface( )) call GetAttachedSurface( ) to get a surface pointer for the back buffer.
-
Create one more surface of type Off screen for the background image of our game. Load the background image you want on this surface. For this, use the ::LoadImage( ) and BitBlt( ) functions. You have to acquire the device context by calling IDirectDrawSurface::GetDC( ) to make BitBlt( ) work.
-
Other game elements like balloon, arrow, robin images are created in a similar way by first creating an off screen surface for them and later blitting the image onto the surface.
-
Override the Run( ) virtual function in the CWinApp derived class to perform custom idle processing. Whenever windows messages are not available, call a function in the CWnd derived class. This function should blit the background, sprites onto the back buffer surface and then flip it with the primary surface by calling IDirectDrawSurface::Flip( ).
-
Add various mouse handlers in the CWnd derived class which would help manipulate the coordinates of the sprites like balloon, arrow etc.
Further Improvements
-
Allow the users to select different backgrounds and robin images.
-
Add different levels of complexity for the user to play.
-
Add a stop watch. When time is over stop the game.
-
Give each balloon different points and make them move at different speeds.
-
Program should judge the players competency.
-
Provision to store high scores with names
-
Modify balloon and robin images so that they appear in 3D.
-
Add an extra frame constituting of trees. Balloons should go behind the trees confusing the shooter and making the game difficult to play.