Topic : DOS Game Programming
Author : Alexander Russell
Page : << Previous 11  
Go to page :


art to m13 and rle sprites
Get palette from art
How to proceedWhen doing a large game it is common to get started with simple `place holder' artwork for testing. Replacing art is easy. Sound and music, which we do not cover, is almost always done with a sound library. Then the actual game programming is done. Utilities, and small test programs are done first. You want to get the various parts working well on their own before adding them to the game. This simplifies debugging immensely. If you try to program the whole thing at once and it doesn't work (I can guarantee it won't work the first time) it is very difficult to tell which part is failing.
There is no one right way to write a game, but here is an idea of one way to start.

Get basic sprite primitives working.
Get user input (mouse, keyboard, joystick) working.
Get art ready, and plan screen layout.
Get paddle control working, including joystick calibration.
Get drawing and erasing bricks working.
Get bouncing the ball off the paddle on an empty screen working.
Get hitting bricks working.
Get scoring working.

Always put a fair amount of effort into designing an easy to use interface for your game. If the player cannot use the controls effortlessly the game will fail.
This is the complete source code for a simple break out game
Click here for chap6.zip (31 KB)

Chapter 6 Exercises
1. What are two ways to change the speed that a sprite moves across the screen.
2. In the Chap6.c source code an array holds information on which bricks have been hit, and their value. Why does this array include information for the part of the screen in between the sections of bricks?
3. Change chap6.c so that all the global variables are contained in a structure. Why would you want to do this?
4. Make a title screen appear at the start of the game. It stays on screen until a button or key is pressed, or 15 seconds elapses.
5. Load up a dark coloured patterned background at game startup.
6. What code do you change to make the joystick more responsive?
7. Make the game drop a second ball if 20 bricks are hit in a row. You only lose a `life/ball' if there are no active balls.
8. Change chap6.c so that the ball is moved by changing its direction, as an angle, instead of using dx, dy. This will require using trigonometry. Use a double to store the angle. Is this faster or slower? Are there any advantages to this method?
9. How could you speed up calculating sine and cosine in a game?
10. Change the game so that the paddle can be moved up a few paddle widths, as well as back and forth.

Page : << Previous 11