|Version: 0.53||Date: 2001-07-27|
|Author: David Joffe||Email: firstname.lastname@example.org|
Dave Gnukem is a 2D scrolling platform shoot-em-up. It is similar to (and inspired by) Duke Nukem 1. The main character has been "borrowed" from DN1, perhaps temporarily.
This started out as an exercise for me in learning C/C++, back in 1995, using DOS and EGA graphics. It was then moved over to Linux using the GGI library. After that it was ported to also run on Windows using DirectX. As from version 0.53, GGI and DirectX have been removed and the SDL library (http://www.libsdl.org/) is now used.
Dave Gnukem is playable, but very much still in development.
The game is OpenSource - contributions of levels, code, graphics sound and ideas are all more than welcome! (And probably necessary if this thing is ever going to get finished ..)
This software is Copyright (C) 1998-2001 by David Joffe. There is ABSOLUTELY NO WARRANTY for this product. This software is distributed under the terms of the GNU General Public License. Please read the file COPYING in the distribution for details, or visit http://www.gnu.org/.
Dave Gnukem is distributed in a zip file, which includes the source code and precompiled binaries for Windows and Linux.
Unpacking the archive If you are using Midnight Commander, you can just hit "enter" on the file. You can also unzip it with KDE's "kzip" utility, and probably with GNOME's "guitar". Real men, however, use the command line:
$ unzip davegnukem0.53.zip
Change to the subdirectory created, DaveGnukem/DaveGnukem. There you will find two executables:
davegnukem - the game
ed - the sprite and level editor
You may need to enable the "execute" attributes on these files (e.g. "chmod u+x davegnukem ed")
To run the game from the commandline, type
To run in full-screen mode, use the "-f" option:
$ ./davegnukem -f
For this to work, you may need to have a 320x200 modeline in your X config.
Unzip the zip file using a utility such as WinZip, or using Windows Explorer if you have WindowsME. Change to the DaveGnukem/DaveGnukem directory, and run DaveGnukem.exe. If you want to run in fullscreen mode, run the supplied batch file "DaveGnukemFullscreen.bat".
HISTORY.txt - Program changelog
TODO.txt - Project TODO/buglist
COPYING - GNU General Public License
Arrow left/right Move hero Arrow up Action key (open doors, activate teleporters etc) Ctrl or P Jump Alt Shoot Arrow up + L Cheat - next level Arrow up + K
Cheat - get all door keys
Arrow up + I
Cheat - go to level exit
Escape Bring up game menu
The level editor ed (Leved.exe in Windows) allows for editing of levels and sprites, and has two modes for these tasks, level edit mode and sprite edit mode. The two modes can be switched between with F4 and F5. The editor starts up in sprite edit mode.
Each game level consists of a 128x100 2D grid of cells. These cells are filled with sprites. The grid contains 2 layers of sprites. The first layer is the "background layer", and on this you place background stuff like walls, floors etc. The second layer (the "foreground layer") is superimposed on top of the background layer, and on it you place things with special functions: doors, keys, monsters, food, etc.
Sprites can have transparency. The transparency is specified in the alpha channel of the TGA file. Where a sprite in the foreground layer is transparent, the background layer shows through. When a sprite in the background layer is transparent, the level background image (which does not scroll with the world) shows through.
NB: NOTE: While you are in the editor, you are either in "foreground edit mode" or "background edit mode". Placing items with the mouse will place things on the layer you are currently on. Use "x" to toggle foreground layer edit on/off - you'll be using this all the time. It is easy to forget which mode you are in and end up placing sprites on the "wrong" layer.
The sprites are divided into "sprite sets"; each set contains 128 sprites.
NB: The Escape key acts as a "quick exit" to the editor. No saving, no questions asked. Be careful with it.
The F1 key will save all sprite sets when in sprite edit mode, and will save all levels when in level edit mode. You must save your changes before you press Escape if you do not wish to lose them
To switch into level edit mode, press F5. To switch to sprite edit mode, press F4.
Sprites are stored in 32-bit TGA format. The alpha channel is used for transparency information. Currently, transparency is only 0/1 - a pixel is either completely opaque, or completely transparent. The TGA's can be created/edited in the drawing package of your choice. I use Adobe Photoshop 6.
Editing sprite characteristics
Each sprite contains various attributes describing it's purpose. There is a "type" attribute, and 12 extra numerical attributes (0 to 11), which I have called "extras". The meanings of the "extras" depend on the type.
Choosing sprite set: Cycle through sprite sets with M and N. Choosing sprites: Use the arrow keys or the mouse to select the current sprite. Sprite attributes:
- Sprite type: This can be selected by clicking on the desired type in the list.
- Sprite color: Use left/right mouse button to choose a sprites color by clicking in the block underneath and to the right of the color palette.
- Sprite extras: To change the numerical values of the 12 extras, use left mouse button to decrement a value, and right mouse button to increment a value. Hold in "control" to increment/decrement continuously. [FIXME: describe meanings of values]
Remember, no changes will be written unless you press "F1"!
Creating new levels
To create an "empty" level file, change to the DaveGnukem/DaveGnukem/data directory and copy the file template.lev to a new file, eg spaceship.lev. You must add an entry for this level in your mission file (see section on mission packs.)
- Cycle through existing level files using Ctrl+M or Ctrl+N. The level filename will show up, and there will be a magnified view (1:1) of the current selection.
- The magnified portion of the level that is shown on the top right of the screen can be selected either by using the arrow keys, or with Alt+LeftMouseClick in the level overview on the left.
- Still use M and N to cycle through sprite sets.
- You can choose two sprites to draw with, using left mouse button and right mouse button. You can click in both the overview area and the magnified view to place sprites.
- By default, you will be drawing on the background layer. Use X to switch to and from editting on the foreground layer.
- No changes will be written unless you press "F1"!
- Some sprites (usually placed on the foreground) are special; they will never appear as is in the actual game. Rather, they are just used to mark the positions of real objects in the game.
- The yellow stick man will act as hero's starting position, the arrow indicates the direction he will be facing when he starts. Only place one of these! If you place more than one, the bottom-most one in the level will be used.
- The purple stick men will be replaced by real monsters. The small number next to the stick men indicate which type of monster is placed. Do not place the sprite for the actual monster graphics - they will appear in the game but do nothing at all.
- There is a blue "EXIT" in the first sprite set. Use this one to mark the level's exit. It will automatically be replaced by a more decorative graphic in the game. Do not place the decorative version in the level.
- To set teleporters, use the "T" sprites with a number. There is more than one teleporter, and each is numbered. There must be exactly two teleporters of the same number in one level!
Here are some examples of how the sprite "type" attribute is used:
- Conv left/right:left, right conveyor belts
- Key, DoorActivator, Door:keys, keyholes, doors. Note that each key, door etc is numbered (extra). So door no 2 goes with key no 2 and dooractivator no 2.
- HeroStart:Hero's starting position
- TYPE_BOX An object of type BOX can contain (optionally) other sprites. These sprites can be any valid sprite that you place in the level, including other boxes :) When you shoot the original box, a new object is spawned, based on the values in extras and extras. Extras is the spriteset of the new sprite, and extras is the sprite index. Use 0,0 for an empty box. The level editor displays what is inside the boxes.
- TYPE_LETTER There are six letters. These SHOULD be placed using the gray boxes that contain them. Traditionally the hero must collect these letters in the correct order to get some bonus points. Extras contain the sprite number, as a zero-based offset into the word GNUKEM.
Sets of levels and sprites can now be grouped together into "missions". A "mission" is roughly equivalent to a Duke Nukem 1 "episode".
NOTE: If you just want to create some new levels, then you don't need to worry about "mission packs" and you can skip this section.
Each mission is described in a .gam file in the data directory. The list of missions available to the game is in the file data/missions.txt. So to create a mission pack, create a .gam file (perhaps by doing a "cp data/default.gam data/spaceship.gam") and then add the line spaceship.gam to data/missions.txt.
Look at data/default.gam to get an idea for the layout of a mission file. Each mission pack has a name (one line) and a description (multiple lines.) Then there is a list of levels, then there is a list of spritesets.
Each level in the list of levels is formatted like this:
filename.lev,Name Of Level,Author Name
Each spriteset in the list of spritesets is formatted like this:
IDNUMBER,filename.tga,filenamespr.dat,Name of spriteset
filename.tga is the sprite image. filenamespr.dat is a file containing the attributes associated with sprites (sprite type, extras, color etc.)
The IDNUMBER is a number from 0 to 255. It is important to understand how this is used. The first 16 (ID's 0 to 15) are "reserved" by the actual game. Currently, only the first 8 are actually used (0 to 7) and 8 to 15 are reserved for future use, so we'll ignore spritesets 8 to 15 for now.
NB: The first 8 spritesets, with ID's 0 to 7, must still be defined in your mission file! If you do not, the game will probably crash. Typically, you will use the supplied default 8 sprite files to define spritsets 0 to 7; that is, def0.spr,def0spr.dat etc. See default.gam and foo.gam for examples of this. Your first 8 spritesets will probably look like this then:
Advanced: For ID's 0 to 7, you do not strictly have to use the supplied sprite files (defN.spr etc). However, the game references sprites in these sets explicitly by ID number and offset, meaning that if you change them, the game will still try draw certain things (like exits and teleporters) from where it expects them to be in the spritesets. Thus, you will be able to change the appearance of (say) exits and monsters in your supplied spritesets, but you will never be able to change where the exit is located in the spritesets.
If all this has confused you, then don't worry. I don't understand it either. Just copy the 8 lines above, as is, into your list of spritesets and then never worry about it again.
Once you have set the "default" spritesets, and you wish to create more sprites not supplied with the game, you can start adding your own from 16, eg:
Note that your own spritesets are added from 16 onwards. Also note that each section ends with a "~".
It is important to note that the ID number is used in the level files. Thus, if you later on change the ID numbers, the ID numbers in the level files will point to the wrong spritesets (or none at all.) So, once you have decided that (for example) your spriteset for the spaceship graphics is ID 25, stick with 25.
All of the above should be telling you: planning is important!
Dave Gnukem will attempt to run in full-screen mode when passed "-f" on the command line.
Note that for full-screen mode to work under XFree86, you will probably need a 320x200 "modeline" in your X configuration file (usually /etc/X11/XF86Config).
On Windows, the "DaveGnukemFullscreen.bat" batch file can be used to run Dave Gnukem in full-screen mode.
Change to the directory DaveGnukem/DaveGnukem.
Edit the Makefile if you want/need to make changes to the setup.
make - compile the game, davegnukem
make ed - compile the editor, ed
make fixme - display list of FIXME's in the code.
make linecount - count the number of lines of code :)
make clean - remove binaries, object files etc.
make dist - same as clean, except doesn't remove binaries.
Speed optimizing: If you want/need to coax a bit of extra speed out of Dave Gnukem, you can do a couple of things. In the Makefile:
- Remove "-DDEBUG" from CFLAGS.
- Add "-O" to CFLAGS to enable optimizations.
- Add "-m486" to CFLAGS to enable 486-specific optimizations. (-m586?)
This should get you between 5 and 20 % speed improvement.
Visual Studio 6 workspace and project files are available in the subdirectories vcDave and vcEd under the "src" directory, for the game and level editor respectively. Open the workspace (.dsw) files in Visual Studio.
NOTE: By default, the working directory will be incorrect and the game and editor will give errors when run. Under project settings, set the working directory to "../../". Add a "-f" to "program arguments" if you want full-screen mode. The reason for this problem is that those settings are saved in big "temporary" project files by Visual Studio, which I leave out when distributing the software for size reasons.