 |
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
named map . Its [0][0] element corresponds to the top left block of
the dungeon. The first index is the vertical co-ordinate and the second the
horizontal one.
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 [0][0] contains 0, which is a plain wall block, element [0][1] contains 1,
which is a sideways wall block. Element [0][2] 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 screenX-1
or screenY-1 blocks. This means that the map array will
be 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 [10][27].
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 map array.
Special conventions
- 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.
|