Building a dungeon
It's far from trivial to explain how a general dungeon works, based on my
current 2-by-1 room example, but I'll try. First we should observe what
the game screen would look like if the dungeon was drawn in its entirety.
Basically, a dungeon is defined by the two-dimensional array of integer values
map. Its  element corresponds to the top left block of
the dungeon. The first index is the vertical co-ordinate and the second the
The integer values in that array are exactly the numbers of the background building
blocks that will make up the dungeon when it's drawn on the screen. In this example,
element  contains 0, which is a plain wall block, element  contains 1,
which is a sideways wall block. Element  is another sideways wall block, and so
on. That's all you need to know. The applet will take care of the rest by using
the information in the various constants.
Important: Note that the "rooms" of the dungeons overlap. The right-hand
side wall of room (0,0) is the left-hand side of room (0,1). The same would apply
to top and bottom walls if the dungeon also extended vertically. Each room is
screenX blocks wide and
screenY blocks high, but when the
player enters another room, the "visible window" thus only moves
screenY-1 blocks. This means that the
map array will
totalYScreens*(screenY-1)+1 elements high and
totalXScreens*(screenX-1)+1 elements wide. (See the "Tweaking and tuning"
page for details.) In our case, that's .
The "What parts of the code need to be changed" page has information about where in
the applet to put the code that fills up the
- Each room must have at least one staircase down to the basement, from which
guards can emerge. Two are recommended.
- Each room must have at least one way out through a wall that brings the player
or the prisoners nearer to the exit. No dead ends are allowed.
- All prisoners, except possibly the chained ones, must be locked up.
- Apart from the final exit, there must be no openings in walls that would let
the player disappear from the dungeon.