There are a couple of options for building a NetHack front end. Some graphical versions of NetHack are true front ends meaning they are only additions and do not modify NetHack. Others are more correctly referred to as graphical variants, they are modifications of NetHack that include changes to the source code for rendering graphics. Even though the later are not technically front ends, the differences are largely invisible to the player, so I've included information regarding both.
A note for those less familiar with older roguelike development: 'console' refers to the command line interface.
Direct Source Code Development
NetHack is open source and has been ported to a variety of languages and platforms. The most direct way to build a front end is to use the source code directly. This option provides the most flexibility as you have full access to the internal workings of the game. It's also probably the most complex, as you will need to develop a good working understanding of the source code. Essentially you:
- determine the layout for conveying the game information to the user
- develop your graphics
- replace the output calls with graphical equivalents
From what I understand, this is how the Nintendo DS version works as it was ported the source was modified to support sprite output.
Note: sometimes instead of replacing the output, it is actual supplemented. That is graphics are added, but the console output is left in place as it can be useful for debugging and can reduce the number of changes (and thus opportunities for bugs) in the source. The ASCII output window can be minimized or redirected to /dev/null
if needed.
Interpret NetHack's Output
It is possible to translate the console output from NetHack into graphics. This is the approach used by Necklace of the Eye (NotEye in short) - it uses a Lua script to interpret NetHack's console output and determine how to replace the ASCII text with a graphical interface. While this may be conceptually simpler than understanding the source code for the game, it still requires a complete understanding of the game itself & the possible output. Generally speaking, the steps would be something like this:
- determine the layout for conveying the game information to the user
- develop your graphics
- intercept the console output
- interpret the console output
- display graphics
- pass user input back into the console game
There are at least a couple of ways to implement this approach - to the best of my knowledge, they are OS family specific. At one end of the spectrum, you could use something like command line pipes. More complex solutions (like those in Necklace of the Eye) rely OS APIs, using things like getstdhandle
or posix_openpt
.
Modify an existing front end or variant
Instead of starting from the original source, you could modify an existing graphical variant or front end. Some are open source and can be directly changed. Others can be changed via scripts or config files. The exact steps for this route will vary greatly depending on which particular variant / front end you are attempting to change & the types of changes you are making.
Modify a tileset
The easiest, but also least flexible option is to start with a graphical version of NetHack that uses a tileset (sometimes just called tiles or sprites) and change just the graphics. Using this approach you are limited to graphical substitutions. You likely won't be able to change the location for displaying health for instance, but you could replace the sprite for an item or enemy with a different sprite.
The RogueBasin NetHack page is a good resource for NetHack variants & front ends. There's also a variety resources posted on the NetHack Wiki.