SRB2 Doom Builder tutorial/Creating level boundaries
This article or section should contain one or more images. Please spruce up the article by adding an image. |
In this chapter, you will learn how to create a small testing stage that can be played in SRB2. While doing this, you will also be introduced to some basic terms and rules of level editing, learn about the attributes of sectors and linedefs, and learn how to create a thok barrier.
Sectors
The first thing you need to do is create the boundaries of your level by drawing a large sector. This sector defines the edges of your level, and everything beyond it will be unused space. To do this, go into Lines Mode and right-click anywhere on the grid. A red dot will appear where you clicked. If you move your mouse away from it, you will see a yellow dot moving with your mouse, and a yellow line connecting the two dots. The dots are vertices and the line is a linedef. In the middle of the linedef, you can see a number that shows how long the linedef currently is, measured in fracunits. Fracunits are SRB2's unit of distance. As a point of reference, Sonic can jump about 100 fracunits high. This measurement will seem a little strange at first, but you will quickly get a feeling for it.
If you right-click again, the yellow vertex will stay in the place where you clicked and the linedef will stop moving. You have now permanently created the linedef. A new yellow vertex and linedef will appear so you can place another linedef connected to the first one. This will continue indefinitely until you place a vertex on top of the very first vertex. Then the linedefs loop and you have thus created a sector.
Sector properties
Now go into Sectors Mode and right-click on that sector. It doesn't matter for now if your sector looks weird; we will delete it and create proper sector later on. A window will appear that shows the properties of the sector:
- Sector Effect: Here you can give the sector a special effect, either by selecting from the four drop-down boxes or typing in the effect number if you already know it. Sector effects include death pits, sectors that end the level, team bases for CTF and many more. There are four drop-down boxes because the effects are divided into four groups, which allows you to combine certain effects with each other. We will take a closer look at sector effects later on.
- Ceiling height/Floor height: Here you can specify the ceiling and floor height of the sector, also measured in fracunits. They can also have negative values, but the ceiling must always be above the floor. The program automatically calculates the total sector height from these two values and displays it below the two fields.
- Brightness: Here you can choose how bright the sector is. 255 is full brightness while 0 is pitch black. In most cases, the brightness shouldn't be below 128, because that is already very dark. You can type in a value yourself or you can select one of the values from the drop-down box. Since the game actually only has 32 different light settings in software mode, these will normally suffice.
- Flats: Here you can specify the flats, which are the graphics that the floor and ceiling will display. If you haven't modified these boxes already, the label for the ceiling should read
F_SKY1
and the label for the floor should readGFZFLR01
. The box above that label should show the checkered brown graphic that is used in Greenflower Zone. You can double-click on the box to open a window with a selection of all flats that are currently used in the level. Press the Tab key to view all available flats in the game. The "Set as build defaults" checkbox will make the two currently used flats the default for the map. - Tag: This is very important for later on, so don't change it. We will come back to this in a later chapter.
- Adjacent Sector Info: Lets you view the floor and ceiling height of any sectors next to this one.
- Sector description: You can put notes here.
Invalid sector configurations
Before we create a proper sector, you should know what constitutes a valid sector and what doesn't. Invalid sectors will produce graphical glitches and may even crash the game, so you must always make sure all sectors in your map are valid. There are two limits to the shape a sector may have: Firstly, two linedefs may never cross each other. Instead, if you want two lines in your level to cross, you should always place a vertex at the crossing point. This vertex splits the linedefs in half so that none of them touch each other directly.
Secondly, sectors must always be closed. That means that they must always consist of a full loop of linedefs and may not have any openings. While unclosed sectors are theoretically possible to make, they can lead to unexpected behavior and glitches. You can check if a sector is closed or not by hovering your mouse over it in Sectors Mode. The linedefs that belong to the sector will be highlighted with yellow. Make sure they form a full loop.
Thok barrier
Now we will create a proper sector that we can use as a test stage. A simple square that is fairly large will do. Delete your old sector by selecting it (left-click in Sectors Mode) and then pressing the delete key on your keyboard. Now go back into Lines Mode and draw a square sector that is about 2048×2048 fracunits wide. This will be our test stage. Go into Sectors Mode and right-click on the sector. You will see that the floor height is 1024 and the ceiling height is 4096. These are a bit too high for our purposes, so give it a floor height of 0 and a ceiling height of 1024.
Since we now have a sector, you might think that the stage is now ready to test. However, if you click on the Test Map button in the toolbar, you will see that SRB2 will start up but immediately crash with the error message "Level has no nodes". This happens because SRB2 requires every level to have at least two sectors. To add another sector to the level so we can test it, we will create something called a [[thok barrier00. In previous versions of SRB2, due to the way the game was programmed, players could sometimes walk through the outer walls of a level and thereby leave the level boundaries. This was fixed by creating a sector that surrounded the entire level, which was called a thok barrier. This sector acted as a solid wall that blocks players.
Thok barriers are no longer necessary, but they are still useful for controlling how high the outer walls of outdoor rooms that show the sky are. To create a thok barrier in your test map, draw another sector around the first map. Although the shape of the thok barrier doesn't matter, it's practical to make it closely follow the outline of the level, so in our case you should also make it square. Always leave a bit of space between the thok barrier and the inner sector, for example 32 fracunits.
The floor and ceiling height of the thok barrier must be identical to each other, so that its total sector height will be 0. They should be somewhere between the floor and ceiling height of the inner sector. So in our case, the floor and ceiling height of the thok barrier must be at least 0 and at most 1024. The height itself determines how high the outer walls that surround the level will be. Let's use a value of 128. Now the outer wall will be 128 fracunits high, which is higher than Sonic can jump, but low enough to see the edge of the boundary. In indoor rooms, a thok barrier isn't necessary, but if you do use one, it should stretch all the way up to the ceiling.
Linedefs
You now have a thok barrier, but your stage is still not ready to test. Go into Lines Mode and hover over one of the inner linedefs with your mouse. You will see six boxes on the panel at the bottom of the window, divided into a "Front Side" and a "Back Side" category. You should see a red "Missing Texture" warning in the third box of the "Front Side" category. Textures are for linedefs what flats are for sectors. They are the graphics displayed on the walls of the level. As you might remember from the opening paragraph, each linedef has two sidedefs. Those two sidedefs are the "Front Side" and the "Back Side" shown in the panel, respectively.
Since the linedefs of your inner sector don't have textures where they should, the game won't know which graphics to display for the outer walls of the level and will exhibit a visual glitch called the hall of mirrors effect if you load the map. To prevent this, we will now give these linedefs textures. To select all four linedefs, left-click on them one by one and then right-click on one of them. You can also select the whole sector in Sectors Mode and then go back into Lines Mode. Then all linedefs belonging to that sector will be automatically selected. After right-clicking on one of those linedefs, a window with two tabs will pop up:
Properties
- Linedef Action: Linedefs can be used for several special effects in the level. Those special effects are selected here. We will come back to this later.
- Sector Tag: You might recognize this from the sectors window. As before, don't change it, since it will be important later on.
- Flags: This is a list of checkboxes. Each of these checkboxes represents a flag. With the use of flags, you can change the behavior of linedefs. Most of these flags are only useful for the previously mentioned special effects, but some do something on their own. The Not Climbable flag will prevent Knuckles from being able to climb the linedef's walls, hence the name. The Block Enemies flag will prevent enemies from attacking the player as long as this linedef is between them. The Impassable flag will prevent most objects (including the player) from crossing the linedef. The Bouncy Wall flag causes the player to bounce off the linedef's walls when touching them. The other effects will be explained later on.
Sidedefs
This tab has two fields, one for the back sidedef and one for the front sidedef. Since not every linedef has a back sidedef, the back sidedef checkbox might be unchecked in some cases. For both sides, the settings are the same.
- Sector: This specifies which sector this side belongs to. In our case, it should be 0 for the front side and 1 for the back side, since our front sides are part of the inner sector and the back sides of the same linedefs are part of the thok barrier. Theoretically, this value doesn't need to match the sector that a sidedef is physically part of, i.e. the sector that it actually faces. For example, you could put "7" here and then the sidedef would be part of sector 7 even if that sector is somewhere else in the level. Of course, you should never do this because it will lead to severe rendering issues. However, there are some situations where the value you see here might actually be wrong and you need to change it manually. For example, this can happen after copy-pasting sectors incorrectly.
- Texture Offset: This controls the offsets of the textures on this side. You will often need to give a texture offsets to align it with the textures of the surrounding linedefs. The first box is for horizontal offset; a positive value will push the texture to the right, a negative value will push it to the left. The second box is for vertical offset; a positive value will push the texture upwards, a negative value will push it downwards. You can also use the "Visual Offset" button to shift the texture around manually.
- Textures: Here you can set the textures for the sidedef, similarly to how you set the flats for sectors as explained above. The boxes are, from left to right, for the upper, middle and lower texture. What these are will be explained in the next chapter.
In our case, a lower front texture is missing. Double-click on that box and you will see the same window as the one for the flats, only for textures. GFZROCK
should be visible as the only option, so choose that as the texture. Your map is now ready to be tested. The only thing that needs to be done beforehand is placing a spawn point for the player. To do this, go into Things Mode and simply right-click somewhere inside the inner sector. Since the spawn point, called Player 1 Start, is automatically the first Thing to be placed, you can now test your map. Click on the Test Map button in the toolbar, point the "Executable" box to "srb2win.exe" inside your SRB2 folder and click on OK.