Chapter 5

            A walkthrough to creating a simple level


This chapter will guide you to designing your first level.
It's very much written like a cook-book - you don't have to
understand exactly what you're doing; if you follow the
instructions, it'll work out ok :)

Details about working with BUILD can be found in the next
chapter.


5.1  Planning


Remember: we have to plan the map first.
For our first map we'll build a very simple map: a storage house
on a street. It will include a door, a window and have a sloped
roof.


5.2  Getting ready


If you're still in Windoze, get out. It'll do you good, and both
Duke3D and Build run better under DOS.

I'm assuming that you've installed Duke3D on your hard drive on
C:\GAMES\DUKE3D and that your duke CD is in drive F.

So now you'll have to copy the editor into your Duke3D directory
as well:
CD C:\GAMES\DUKE3D
XCOPY F:\GOODIES\BUILD\*.*

Now start up BUILD.EXE. A screenfull of legalese will pop up (in
effect it says that you can't copy BUILD and should only design
maps for the commercial version of Duke3D - obvious). Press ENTER
to get rid of it and -voila!- you're in the 2D mode.


5.3  Creating a new map


Press [Esc]. On the bottom, a small menu will pop up:
(N)ew, (L)oad, (S)ave, save (A)s, (Q)uit
Press [N].

Asked 'Are you sure you want to start a new board?', you press
[Y].
Note to non-US users: the program reads your keyboard directly
and thus expects you to press the key right next to [T] - for ze
Germans, this would be [Z].

The new map will automatically be called NEWBOARD.MAP -
overwriting any file with that name in your directory. So be sure
to use 'save (A)s' the first time you save your map.


5.4  The 2D screen


The screen in front of you now is the 2D mode, where you'll be
doing all the rough work like laying out your rooms and
corridors. You are currently viewing your map from above.
(Changing room heights, textures, etc are done in 3D mode, so be
patient).

The screen consists of several parts:

5.4.1  Map

Most of the screen is given over to the map itself. Currently
it's just displaying a grid.
All line endpoints and all sprites will automatically align
themselves with the grid (making it easy to design rectangular
rooms, for example). You can change the grid size by pressing [G]
several times: try it now. You'll see the grid size shrink and
then disappear (meaning the grid is switched off and you can draw
anywhere). Keep pressing [G] until you see the biggest possible
grid. The biggest (meaning coarsest) grid has points which are
1024 units (that's 256 pixels) apart.

To see the maximum possible size of your map, use the [A] and [Z]
keys to zoom your map in and out. Try it, and then zoom back to a
comfortable distance.

The map also shows a red cross (your mouse cursor) and a white
arrow (your current position).

5.4.2  *Message window*

The message window is the bit just below the map: on the left it
shows the text 'BUILD V041996 BUILD by Ken Silverman'.
The right part of the message window currently just shows a red
line - that's where the program will display messages and ask you
for any info it needs.

5.4.3  Data window

The data window displays info about currently selected objects
(like sectors, walls or sprites) and can also show some help
texts.
Right now it should be empty.

5.4.4  Info window

The info window also consists of two parts: on the left is your
current (x,y) position in units as well as your viewing angle.
On the right it shows how many resources you have used up
already. Interesting, because it shows you the limits imposed by
the Build engine: you can have a maximum of 1024 sectors, 8192
walls and 4096 sprites.


5.5  Moving about


As said, the white arrow is your position and heading on the map.
You can move about in two ways:

Cursor keys    Like in the game, these move your forward and
               backwards. You can also rotate your heading.
               Interestingly, it also prohibits you from walking
               through blocking walls - this way you can see if
               the player will actually be able to walk
               everywhere he should be.

Mouse          The red cross is your mouse cursor and therefore
               (surprise!) moved with your mouse. Pressing the
               right mouse button transports your position to the
               mouse cursor - try keeping the button pressed and
               moving your mouse to see what happens.


5.6  *Creating a room*


So, let's start by building the street first.
Move your position somewhere into the middle of the map and zoom
in until you're at a nice comfortable distance (three squares of
the grid should be about an inch in length on your screen).

Now point the mouse at the bottom left of your currently visible
map and press the spacebar.
A small green square appears on a grid point and the message
window displays 'Sector drawing started.' And so it has - try
moving the mouse about on the screen. See that white line? That's
your first wall. Move it straight up by exactly seven squares and
press the spacebar again.

Another green square has appeared, and you've begun drawing a new
wall. Move it exactly 14 squares to the right and press the
spacebar again. Draw the next wall seven squares straight down
and press the spacebar.
The last wall you'll end exactly on the first point created, thus
forming a neat rectangle.

When you pressed the spacebar for that last square, the lowest
wall started flickering. This means that it's the currently
selected wall. Press [Alt]-[Tab] to get some info on the wall.

Don't worry about what all that stuff means - the only thing of
interest right now is the Wall number: the one on the bottom is
wall number 4.
Move the cursor near the other walls and note how the other walls
get selected. The info at the bottom, however, is not
automatically updated, so you'll have to press [Alt]-[Tab] for
each wall again.

Just press [Tab] now and have a look at the sector info. All that
stuff is explained later in the FAQ, it's not important right
now.


5.7  *3D mode*


Make sure the white arrow is inside this room and press the
[NumEnter] key. This is the Enter key on the bottom right of the
numeric keypad (the big one in the middle won't work for us).

Wow! 3D!
You're now inside your room. It's still somewhat narrow and has
walls consisting of ugly gray stone. That stone, by the way, is
that ugly on purpose. It reminds you that you still have to find
a nice texture for it.

In 3D mode, two things are of particular interest:

The mouse      The mouse cursor has changed into a white cross -
               you use it to point at the things you want to
               change: walls, sprites...anything.

FPS            On the top left is the FPS (Frames Per Second)
               counter. This is the speed at which the screen is
               being redrawn.
               This number is terribly important while designing
               your level: if it drops too low (below 10), the
               level will play jerky and you won't enjoy it.
               The FPS are connected to the complexity of the
               displayed image - the more walls, sprites and
               textures the computer has to show on a single
               screen, the lower the FPS count will be.
               As the Levelord says: "Framerate is God!". So keep
               an eye on it.

You can move about in 3D mode with the cursor keys. Don't use the
cursor keys from the numeric keypad but the ones in the middle.

You can jump back and forth between 2D and 3D mode by pressing
the [NumEnter] key.


5.8  Raising the roof


This is supposed to a street scene, right? So the first thing
we'll need to do is raise the roof.

Point at the ceiling and press [PgUp]. You can see it move
upwards a bit, pulling the walls with it. Point at the wall in
front of you and press [PgUp] again. That's another way to raise
the ceiling.

Raise the roof until you reach a height you feel more comfortable
with. The room should now resemble a small aircraft hangar.


5.9  Textures


Now for some magic: let's change the appearance of the walls and
floor.

5.9.1  The floor

The floor is first: we'll change it from a simple and ugly stone
to a street. Point at it and press [V].

The screen clears, showing the current texture at the top left
and the number '0' at the bottom left. This screen contains all
floor textures you have used on your map so far, and the number
'0' is the number of the currently selected texture.

Press [V] again: now you'll see a list of _all_ textures in the
game, including things which are actually sprites (like the
weapons), but can be usd as textures if you want (although
they'll usually look weird).
You can move your cursor (the white box) about with the cursor
keys - try it.

Have a look at all the possibilities.
Now press [G] (meaning Goto). The program will ask you 'Goto
tile:' on the top left. Use the backspace key to erase the
currently shown number and type '815'. Press [Enter].

Voila! The floor changed its appearance and now looks more like a
street.

5.9.2  The roof

Now for the roof. The street has sky above it, right? So, using
[V] again we'll select tile number 89.

This looks weird, not like the sky at all. So we parallax it:
point at the roof and press [P].
Much better! Move around a bit, using [Ctrl]-[A] and [Ctrl]-[Z]
to look up and down. (Yes, if you look too high, the texture will
mess up - it's the reason most outside areas are so high and
narrow in the game. Keep your eyes low for now :)

5.9.3  Flying about

There are three movement modes available to you in the 3D view:

Game Mode      Here you walk around like the player in the game.
               Use [A] to jump and [Z] to duck.

Height Lock    In this mode, you're always at the same height
               above the floor. Use [A] and [Z] to raise and
               lower yourself.

Float Mode     You're completely unaffected by the floor and can
               smoothly change your height with the [A] and [Z]
               keys.

Use the [CapsLock] to change between these modes.

5.9.4  The walls

Currently we're still sitting in a walled-in box. Let's make this
look even more like a street.

Point at the west wall and give it the texture number 794.
Now this looks more like a house. However, I bet the windows are
not perfectly aligned with the ground and you only have half the
lowest row showing.

So let's change the orientation of the wall texture. Point at the
houses and press [O]. Hmm, the texture now hangs from the roof
instead of the floor.
Still not good enough. Press [O] again and raise the ceiling
until you have three rows of windows, looking just right. Walk up
close to it, making sure it looks ok.

Now we'll copy this texture to the other four walls: Point at the
west wall again and press [Tab]. This copies the texture into
memory, causing some text to appear: 'Lo = 0/hi = 0/USED= 1/MEM =
8192'. (Of interest is only the 'USED' value - it shows how often
we have used this texture already).
Point at the three gray walls in turn and press [Enter] on each.

Much better. Now we're standing on a street (or a courtyard).
Note how neatly the textures fit together in the corners? That's
because we stuck to the grid while designing this room in 2D
mode. All textures have width and height in a multiple of 8, same
as the grid. So stick to the grid, and you'll be ok.

Last thing to do now is to make our house stand out. The street
is on the north edge of our house, so point at the south wall and
give it the texture number 723. This changes our house to a
darker, more brooding one.


5.10  Building the house


So far we have a street but no house.

To design the house, we first drop back into 2D mode: press
[NumEnter].

5.10.1  The house sector

Press [G] again, making the grid a bit smaller (exactly by half,
in fact). This is now the second-biggest grid available to us.

Point on the grid just below the lower left point of the street
and press [Spacebar]. Don't draw on the point itself, but one
grid unit below it - if you made a mistake, press [Backspace] and
try again.

Draw a line to the right parallel to the street, along its whole
length. Press [Spacear] under the bottom right point of the
street. That's the first inside wall of the house. The next wall
goes straight down by 8 grid units.
Keep going until you have a rectangle defining the inside of your
house.

5.10.2  Fixing the house sector

Move the white arrow inside the house sector with the mouse
(notice that you can't move from the street to the house with the
cursor keys, as there's a thin line of nothing (solid rock)
between the street and the house) and switch into 3D mode.

Yuck, there's the gray stone again. Again, we first raise the
roof to a comfortable height (don't make it too high - look at
the room you're in now to get an idea of the proper height).

Now that we have a (somewhat long and narrow-looking) room, we
fix the floor first. Let's make a red carpet on a wooden floor,
like the one we saw in the Bank Roll level.

5.10.2.1  The carpet floor

Point at the floor and give is texture number 749. Hmm, the
floorboards look a bit wide. Point at them and press [E] (toggles
between enlarged and normal floor). Now the wood looks better.

Now how will we do the carpet? After all, we don't want wall-to-
wall carpeting, we want the wood to peek out at the edges.

Since a sector can only have one floor texture, the answer is to
create a second sector inside the house sector. A smaller one,
with the same roof and floor height as the first one, but a
different floor texture.

So we pop back into 2D mode and design a second sector inside the
house. It looks just like the house sector, but is a bit smaller
(one grid unit distance to the walls).

Place the white arrow in the middle of our new sector and press
[NumEnter].
Whoops! A message appears: 'Arrow must be inside a sector before
entering 3D mode'. What happened?
Place the arrow in the narrow space between the old house sector
and the new one and press [NumEnter] again. Whooo - tight!
You see, the old sector is now doghnut-shaped - we've created a
solid block of stone right in the middle of it.

Go back into 2D mode. Point inside the new sector and press
[Alt]-[S].
The walls now turn red, and the message window says 'Inner loop
made into new sector.'.

Back in 3D mode we see that everything is ok now - we have our
original house back. No sign of the new sector, though.
That's because the new sector automagically has the same floor
and ceiling of the original sector. Point at the middle of the
floor, press [V] and select texture number 899. See? There's our
carpet.
Play about raising and lowering the roof and floor of the carpet
sector to get a good understanding of what we've done just now.

When you're done, set the floor and roof of the carpet sector to
the same as the house sector and give all four walls a nicer
texture: 783. Remember that you can use [Tab] and [Enter] to make
life easier.

5.10.2.2  Nice walls

Hmmm. The walls are suposed to have a wooden toe-rail along the
bottom and a dark stripe near the ceiling, and currently they
look wrong.
Looks like we'll have to shift the texture up a bit: point at one
of the walls and press [Shift]-[Num2] (that's the '2' key on the
numeric keypad).

See it move up a bit? Keep pressing [Shift]-[Num2] until the
wooden toe rail is exactly right on the floor (walk up close to
the wall to make sure no single line of brighter pixels is
peeking underneath the wood). Now the wall is so high that the
texture repeats on the upper part, so we'll lower the roof a bit.

Sinve the texture is attatched to the roof, this lowers the whole
wall into the floor. Point at it and press [O] (for Orientation).
Move the roof again and note that the texture is now attached to
the floor, not moving with the roof.

Make the texture look good again by using [Shift]-[Num2]. Then
lower to roof until the wall looks just perfect. Don't forget to
lower the roof of the carpet sector by the same amount, otherwise
it won't look right.

If the other walls are not looking ok, point at the wall you've
been working on and press [.]. This auto-aligns the textures of
all walls (you might have to press [O] on the other three walls
as well).

5.10.2.3  Finally, the roof

The roof also isn't looking to good so far. Give it the texture
number 182. And change the roof texture of the carpet sector to
match, of course :)

5.10.3  Saving your work

Nice. Now just so we don't loose everything, go back into 2D
mode, press [Esc] and [A] (save As). Erase the name 'NEWBOARD'
with [Backspace], type [DEMO] and press [Enter].

Now no matter what happens, we won't loose our work so far.

5.10.4  Building a doorway

The house is well and good, but we're missing something
important: a doorway out to the street.

To create one, we'll need to be in 2D mode and create a sector
connecting the street and the house.

Move to the right of the house and zoom in a bit so you can see
the grid very clearly. Move the cursor just underneath the white
line defining the top edge of the house. See that little black
dot on it just above the red cross? Move the cross until the dot
is exactly three grid squares from the right edge of the white
house sector and press [Ins].

A small green square appears: we've inserted a point on the white
line, splitting it in two. Insert another point on the same line,
two grid squares to the left of the first one.

Now do the same thing to the bottom part of the street sector:
insert two points just above the points on the house sector.
These four new points will now define our doorway sector. Notice
that the doorway will share two lines: the bottom one will also
belong to the house, while the top one will connect to the
street.

Now build the door sector: point at the bottom left point and
press [Spacebar], starting a new line. Point at the point on the
bottom right and press [Spacebar] again. Keep doing this with the
top right and the top left point. End the final line on the
bottom left point, creating a rectangle which will immediately
turn partly red.

That's our new doorway sector. Look at it: the top and bottom
lines are red (two-sided lines) and the left and right ones are
white (one-sided).

Let's view this in 3D: place the arrow on the street and switch
into 3D mode.

Doesn't look too good so far, does it? The doorway reaches all
the way into the sky, appearing all wrong.
So let's make it lower: walk into the doorway, point at one of
the walls and keep pressing [PgDn] until the roof comes into
view.
The roof looks a mess because it's still parallaxed (the doorway
took on the setup of the street sector - notice the floor is
asphalt), so press [P] on it.

Take a few steps backwards into the street and change the height
of the doorway until you're happy with it (it should end just at
the top of the dark windows).
The walls look a bit messy, both over the doorway and inside it.
That's because their textures are attached wrong - press [O] on
them. Much better.
Also change the doorway sectors floor, roof and wall textures to
773.

Now we have a house which we can leave through a doorway and walk
into the street!

5.10.5  Adding a window

So, what's a window? Easy: just like a doorway, but with a raised
floor and some glass in it.

Since you now know how to build a doorway between the street and
the house, go ahead and build another one somewhere to the left
of the first doorway.

Got two alike doorways next to each other? Textures looking ok?
Right, step into the street. Point at the floor of the second
doorway and press [PgUp] to raise it right up to the bottom of
the black windows (looks better).
All right! You've got yourself a window!

However, it still doesn't look good - it's too high up, we can't
look out comfortably. So, lower the roof and floor of the window
sector until you can easily look into the house.

Better, but now it doesn't fit the texture on the street as
neatly anymore. So we'll use [Shift]-[Num8] to shift the wall
texture down until it looks right.
Notice how you're only shifing the wall texture over the window?
Each section of a wall (separated by a point) can have its own
texture, so you'll have to shift each walls texture.
Remember that you can use [.] to auto-align textures for you (it
auto-alignes all walls to the right of the one you pointed at, so
shift the texture on the leftmost wall).

5.10.6  Glass

Now we only need to add some glass into the window (so we can
shoot it, yaaay!).
Still in the street, point on the wall below the window and press
[M]. The window will be walled closed with the ugly gray stone
texture again. Point at it and give it the texture number 503.
Voila! A glass pane!
However, the white reflections on it loks wrong. Press [T] twice
to make the window more transparent.
You can also use [F] (Flip) and [Num4] as well as [Num6] to
change the appearance of the window. (Of course, you can use
these keys on any wall texture). If you make a mistake, you can
reset the wall be pressing [/].

Remember to fix both sides of the glass pane.

Now, all we have to do is make the glass breakable: point at it
and press [B] (blocking movement) and [H] (hitscan on, meaning it
can be shot).

A glass pane on the very outside doesn't look to good, though -
it should be in the exact middle of the window sector. Besides,
it'll mess up the street texture when shattered.

So, first we'll define a line where the glass will be: in 2D
mide, insert a point in the middle of the left and right walls of
the window sector. Point at the first point and (using
[Spacebar]), draw a line across to the second point. The message
'Sector split.' will appear - the window sector is now made up of
two separate sectors, and we'll put the glass on the line
dividing them.
But first, press [B] at the new line in 2D mode until it looks a
normal red. Do the same for the upper line (where our glass is
right now).

Back in 3D mode, we'll remove the old glass pane by pressing [M]
at it and insert the new pane by pointing just inside the window
sector and pressing [M] again. Fix the window up using [Num4] and
[Num6] and don't forget [T], [B] and [H].

5.10.7  The sloped roof

Remember we wanted to slope the ceiling of the house so it looks
a bit like an A-frame?
Well, of course each sector can only be sloped one way, so we'll
have to split the house sector (and the carpet sector!) again:

Insert a point in the middle of each horizontal wall in the house
(the house walls and the carpet sector walls) so you get four
points underneath each other.

>From the top point, draw a line to the one just below it. The
message window will say 'Loops joined.'. Keep going: connect the
two points on the carpet sector ('Sector split.') and the lower
two points ('Sector split.').

Now, still in 2D mode, we define the 'hinges' of the sloping
ceiling. We'll hinge the roof in the middle, so first point
inside the carpet sector just to the left of the new line and
press [Alt]-[F]. This makes the selected line (the blinking one)
the first line in the sector the mouse cursor is in.
Do the same for the second carpet sector (the one on the right)
and with both house sectors.

Do the same for the second carpet sector (the one on the right)
and with both house sectors.

Now switch to 3D mode, point at the roof and press '[' and ']' to
tilt the ceilings. (You'll have to raise the ceiling a bit - use
[.] to realign the walls afterwards).
If the ceiling tilts wrong, you've messed up the [Alt]-[F] bit.
Make sure you've selected the right line at try again.

You can use [/] to make a ceiling straight again.


5.11  Trying it out


Let's try our new level out. Place the arrow in the street and
press [ScrollLock] to set the dim red arrow which shows your
starting point in the game.
Caution: if the starting point is outside a valid sector, the
game will crash if you try to run the map!

In 2D mode, press [Esc], [Q] [Y] [Y] to exit the editor, saving
your map.

Now start up Duke3D by typing
DUKE3D -map DEMP.MAP

Fun! Walk through your creation, smash the window, look about.

However, it sure gets old fast - plain walls with no decorations,
and where are the enemies?


5.12  Decorations


Let's keep our decorations simple: a flowerpot in the corner, a
picture on the wall, a lamp on the ceiling and a burning barrel
in the street.

First call up Build again:
BUILD DEMO.MAP (press [Enter] twice quickly)

We find ourselves in 3D mode, at the player starting point. Walk
inside the house, point somewhere at the floor and press [S]
(insert sprite).
Again, we're confronted with the ugly gray wall, this time
standing upright on the floor.

Try walking around it - note how it always faces you?
Press [R] at it and see how it changes into a flat piece of
paper. You can change its heading in 2D mode by pointing at the
sprite (the small circle with the tail sticking out of it) and
pressing [<] and [>].

Back in 3D mode, press [R] at it again - now it's flat on the
floor.

5.12.1  The flower pot

Make the sprite stand up again with [R] and press [V] to select a
different sprite (number 1025). The wall changes into a flower
pot!
By the way, notice that sprite 1025 looked differently in the
selection list? The pink bits will be transparent when the sprite
is used.

Now shift the flower pot into a corner: in 2D mode, make the grid
a bit finer, point at the flower (now called BOTTLE7 by the
program) and move it about by pressing and holding the left mouse
button (you can shift the endpoints of walls in the same way,
btw).

All right! Now we have a flower pot in the corner of the room.
Press [Tab] at it and use [S] in 3D mode to place some more pots
on the floor. They will automatically shatter when hit.

In 2D mode, the sprite appears pink - this means that the 'block
moveemnt' flag has been set, and you can't walk through it. If
for some reason you want to allow the player to walk through a
sprite (fire, for example), press [B] at the sprite and watch it
change color.

5.12.2  The picture

The next sprite will be a picture on the wall.
Point at the south wall and press [S] again. The flower pot
appears again, but since we placed it on a wall, it's
automatically flat already.

Use [V] to change it into sprite number 1075 - a framed picture.
Use [PgUp] and [PgDn] to position it on the wall.

5.12.3  A hanging lamp

Next we'll hang a lamp from the ceiling.

Point at the middle of the floor and press [S]. Change it into
sprite number 979 (a hanging lamp).
Well, not exactly hanging yet. So point at it and press
[Ctrl]-[PgUp] to move it right up to the ceiling (yes,
[Ctrl]-[PgDn] will place a sprite on the floor).

5.12.4  The burning barrel

Finally, we'll place a burning barrel on the street. Walk outside
and place a sprite number 1240 somewhere on the street.
Note that this sprite will automatically animate to look like a
burning barrel. If you had chosen one of the other three
animation frames (sprites 1241 to 1243), it wouldn't have worked
- the flames would appear 'frozen' (try it).

By the way, you can remove a sprite by pointing at it and
pressing [Del].
You might also want to play around with the [Num2], [Num8],
Num[4], [Num[6] and [/] keys.

5.13  *The enemy appears*


We're still missing opposition.

So, go back into the house and place a sprite number 2000 in the
middle of it.
Ah, a PigCop! Try walking around it - note how you're always
shown the correct side of the monster?

Place another one next to the first one, but as number 2001.
This one isn't moving, and the program calls it PIGCOPSTAYPUT
(check it in 2D mode).
All monsters have a STAYPUT frame - it means that they will walk
around normally, but never change the sector they started in.
Great for setting up ambushes.
It also means that our second PigCop won't dare to leave the
carpet :)

Here's a cute trick: try making one of the cops transparent [T]
to create a ghost :)

Start the game up again, switch to God mode (type DNKROZ in the
game) and watch the different behaviour of the two monsters.

Note that you can place monsters in different poses to have them
start up in them. For example, you can place a PigCop number 2045
(lying down) behind a low wall...


5.14  The other players


All that's missing now is to set up the coop and DukeMatch
starting positions of the other players. You'll need seven of
each (the red arrow is the eight one for both coop and DukeMatch
positions).

Simply place sprites number 1405 (called APLAYER) everywhere you
want a DukeMatch starting spot (be fair!).
To differentiate the coop starting positions (which are usually
all in a bunch somewhere) from the DukeMatch spots, point at them
in 2D mode, press [Alt]-[T], [1] and [Enter] to give them a lo-
tag of 1.


5.15  Taking it from here


All right! Your first level!

It's still a bit simple, so read through the next chapter and
play around (save it first). The trick is to experiment as much
as possible!