Dave Gnukem

Version: 0.53 Date: 2001-07-27
Author: David Joffe Email: davedev@scorpioncity.com
  1. About Dave Gnukem
  2. Credits
  3. License
  4. Requirements
  5. Installation
  6. Playing the game
  7. The level editor
    1. Drawing sprites
    2. Editing sprite characteristics
    3. Creating new levels
    4. Editing levels
    5. Mission packs
  8. Tips and comments
  9. Fullscreen mode
  10. Compiling the sourcecode
    1. Linux
    2. Visual Studio

About Dave Gnukem

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:

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

$ ./davegnukem

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".

Other files:

The game

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

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.

Drawing sprites

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.)

    Change levels

    Tips and comments

    Mission packs

    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:

    4,def4.spr,def4spr.dat,Hero graphics
    5,def5.spr,def5spr.dat,Bullets etc

    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:

    16,mine.spr,minespr.dat,My sprites
    62,ocean.spr,ocean.dat,Ocean sprites

    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!

    Fullscreen mode

    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.

    Compiling the sourcecode


    Change to the directory DaveGnukem/DaveGnukem.

    Edit the Makefile if you want/need to make changes to the setup.

    Make options:

    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:

    This should get you between 5 and 20 % speed improvement.

    Visual Studio

    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.