A map or level is a self-contained area in which the player faces a specific objective. Each act in Single Player mode is a separate map, as are the arenas for Match, Capture the Flag and Race. Maps are laid out on a 2D grid with a map editor such as Zone Builder and then stored in WAD files are a series of lumps.
SRB2 maps are made up of five main components: vertices, linedefs, sidedefs, sectors and Things. The triangle in the picture to the right is a sector. It is made up of vertices (the blue dots at the edges) which are connected by linedefs (the white lines between the blue dots).
- Vertices: A vertex is essentially a point in the map where a linedef ends/begins. Therefore, vertices make up the edges of sectors.They have no other property aside from their location.
- Linedefs: Linedefs are the lines that connect the vertices, and therefore the boundaries of a sector. In-game, they appear as the walls of sectors.
- Sidedefs: Each linedef consists of two sidedefs, which are literally the sides of the linedef. The front side of the linedef is covered by the front sidedef; the back side is covered by the back sidedef. The outer linedefs of a map face into empty space and therefore only have a front sidedef, they are called one-sided linedefs. The graphics displayed on the walls - called textures - are specified on the sidedefs.
- Sectors: A sector is a closed loop of linedefs that forms a section of the map. It includes the properties of the floor and ceiling, which are their heights and the graphics they display - called flats.
- Things: Things are starting points for Objects that should spawn when the map is loaded. Examples of these include the starting points for players, and spawn points for rings, enemies, monitors, and scenery items such as flowers. Things are independent from the rest of the map structure.
For rendering purposes, the linedefs of a map are split into segments (also known as segs) that form sub-sectors, which themselves are part of an existing sector. These sub-sectors are all convex. The game can then determine which sub-sectors are visible from the sub-sector the player is currently in and render these sub-sectors first, which vastly improves the performance of the engine on larger maps.
This process is called node building and must be performed on a map with a nodebuilder before it can be loaded in SRB2. Most map editors include a basic nodebuilder themselves or allow the designer to automatically run a nodebuilder when saving the map. For example, Zone Builder is packaged with ZenNode, the most common nodebuilder, and runs it automatically upon saving a map.
A map is stored inside a WAD file as a series of consecutive lumps, all of which contain a specific part of the information that the game needs to create the map. These lumps must have specific names and must be stored in a specific order to work correctly. No other lumps may be in-between the lumps that make up one map. The map must consist of these lumps in the given order:
- Header: The name of this lump is
MAPxx, with xx designating the map number in two-digit form; to use a slot above 99, extended map numbers must be used. Aside from the name, this lump does not normally contain any other data.
THINGS: Lists all Things in the map as well as their type, X and Y coordinates and other attributes, including flags, Angle, and Z position.
LINEDEFS: Lists all linedefs in the map as well as their type, starting and ending vertices and other attributes, including flags, tag, front and back sidedefs (if applicable).
SIDEDEFS: Lists all sidedefs in the map as well as the sector they belong to, the textures they display and the textures' X and Y offsets.
VERTEXES: Lists all vertices in the map as well as their X and Y coordinates.
SEGS: Lists all segs in the map. Created by a nodebuilder.
SSECTORS: Lists all subsectors in the map. Created by a nodebuilder.
NODES: The node tree which sorts the subsectors into the correct order for rendering. Created by a nodebuilder.
SECTORS: Lists all the sectors in the map as well as their type, tag, floor and ceiling heights and textures, and light value.
REJECT: Contains information about which sectors are visible from which other sectors. SRB2 uses this to determine if enemies currently have a target in their line of sight. If not, they stop their animation until a target is detected. This improves the speed at which the game runs. Optionally created by a nodebuilder.
BLOCKMAP: Contains information about collision detection between Objects and the level environment. Optionally created by a nodebuilder.