# Basic Concepts

| Level ingredients
| Level structuring
| About rooms
| Sector fields - tell us where to move !
| About raycasting
| Summary

Overview

## Level ingredients

A complete Running level consists of:

1. Level structure
   - Rooms (walls, doors, lifts)
   - Movement definitions (called: sector fields)

2. Mobile components
   - Enemies
   - Trains, cars

3. Special and bonus stuff
   - Special components (e.g. beamer, laser barrier)
   - Items (ammonition, medicine)

4. Mission definition
   - Briefing
   - Starting point
   - Level exit
   - Primary and secondary target

Level structuring

## Level structuring

Sector. A level is a container for smaller level parts - called sectors. Sectors allow you to edit a small subpart of the level. It also increases the engine calculations. As the engine only has to calculate the visible parts - some sectors that surround you - the engine can discard those sectors which are far away. An example: when you are doing the dishes in the kitchen the engine doesn't matter about the cellar rooms. As you will see smaller parts make editing much easier.

Input | Input. Each sector consists of room structures (can be more than one room !) and definitions about possible hero movement (sector fields). Both parts are edited in the sector window of the level editor. As you will see the view at level structures in the design phases are always two dimensional (see Running is two dimensional). The working process resembles the process of an architect. Running levels contain plan with lots of lines. In fact, a Running level is made up of lines and points. Thats all. The Running engine on the Falcon renders using this data. The preview component included in the editor can do this too allowing you to gain a first impression of your level design.

About rooms

About rooms (and walls, doors, lifts). What do we need to know about a room ? How many walls, which wall papers, how many doors, is there a box in the middle, a couch, ... ? All room structures are represented by lines. Just define a start and an end point and connect the two with a line - done. Of course the wall only has some default settings. But we can change the line settings (aka wall) after that. You can choose a nice texture for the wall, set the high and width ... Here we have a sample room structure (showing the sector window of the level editor):

Places to move (Sector fields)

Places to move (Sector fields). Walls are just fine. But what about collision detection ? Yes, there might exist more elegant concepts to solve that problem on that planet - but in the early engine days we made a decision: we use special fields which tell the engine where the hero can move and where he can't. The so called sector fields have some additional functions: they include information about the height of them - a rectangular area of the sector with a certain height.

Please note: the look of a room and where the hero can walk are two different concepts.

This leads to more editing work - but also enables the designer to do some very cool stuff (walls you can walk through, walking on an invisible platform).

Definition of sector fields

Definition of sector fields. Every sector contains at least a single movement area (sector field). For each sector field we have set the starting height of the floor and the height of the room in this area. Easy ? Hmm, what about a box in the middle of a sector ? No problem, just add some sector fields around that box with the floor height (green rectangles) and a sector field on the box with an increased starting height (red rectangle).

The black lines in the figure below shows the room structure. The gap between the room lines and the sector field lines are important. They prevent the hero from running too close to the room walls. Every move the hero makes the engine checks the sector field to figure out his current height (maybe he is walking up some stairs) and blocking walls. When he is running toward a box, he will stop right before the box - walk around that obstacle or jump on top of it ...

Sector fields in detail

Sector fields in detail. As the figure below shows sector fields may overlap. An important point is that sector fields always have to be convex. That means that you can get from any side of the rectangle to the other one without hitting another line of the rectangle. Please keep in mind that there is a special editing mode for sector fields.

This picture shows a room definition, sector fields are red and green:

Running is 2 1/2 dimensional

## Rendering the two dimensions to get a 3D picture.

Running is 2 1/2 dimensional. Yep, the Running engine is no 3D engine. There are no free 3D rotations you might have seen in other games (e.g. on PC: Tomb Raider). As you have seen all structures are edited in 2D. Hmm, and how about rendering those structures to 3D ? Here is the solution:

Rays of your eyes

Rays of your eyes. Imagine a rectangular room with a box.

The hero, hence our viewing point, is located in the left lower part of the room (represented by the arrow). Our hero looks to the north. The Running engine calculates with a viewing cone of 90 degrees. The resulting rendered picture will be shown in a resolution of 320x200 pixels (it's your Falcons resolution ...). The viewing cone of 990 degrees resembles the 320 vertical rays (x resolution).

The engine tracks the path of each of the 320 eye rays into the distance. Therefore it treats every ray as an unlimited line and tries to find cutting points with other lines - the wall lines. If a ray cuts a wall line the algorithm calculates the distance of the eye of the hero to the wall cutting point. As the 320 rays resemble the 320 columns of the screen the engine fills up each column with columns (texture columns) of walls found at the cutting points of each ray. In the below example the first ray cuts a wall - this means that in the first column of the screen there is a column of a texture, with a starting height, a height and a certain texture style.

The engine achieves the texture information by reading the line's texture settings. The bigger the distance to the cutted wall the smaller the texture column will be painted on the screen. The engine repeats this procedure for all 320 rays (320 screen columns) - so the player gets a 3D impression of the room. The following picture shows the result of this procedure; texture settings aren't used, the wall is just black.

Using information about height

Using information about height. Another well known engine using this principle of raycasting ist the Wolfenstein3D engine on the PC. However, we added height information to the walls.

This allows us to render things like boxes or stairways. Maybe the box has a height of 40 percent of the other walls in the room. This also means that the painted texture column has only 40 percent height of the wall column. If we also cut and render sides of the box which we face at the backside, then we get the following grey box:

Including wall attributes

Including wall attributes. The Running engine allows us to assign the walls information apart from height like color of the floor and ceiling and the kind of texture. For our small example we don't bother about textures at the moment - we assume the walls have a certain color, that's it.

Let's add some new features to our scene - a grey wall, a brown box with a red top. The color of the floor is black, the ceiling is white.

The following table summarizes the four mentioned attributes of a wall (or at a more abstract level: line):

Color of floor | If the wall line has been cut by a viewing ray, a column in that color will be painted on the screen from the bottom of the screen to the beginning of the wall.
Color of ceiling | If the wall line has been cut by a viewing ray, a column in that color will be painted on the screen starting at the top of the wall to the top of the screen column.
Color of the wall (frontside) | The resulting screen column gets this color.
Color of the wall (backside) | If the viewing ray cuts hits the wall on the backside there are two cases. If also to the line belongs a floor, the engine draws a column beginning at the bottom of the screen to the top of the wall. In the other case, if there is ceiling, the colunm is painted using this color starting at the bottom of the wall to the top of the screen.

The settings for our example. Please take care of the box settings - boxes are special cases.

Room walls (frontside): grey
Floor color: black
Ceilinig color: white, not color for the backside
Box (frontside): brown, floor: black, NO ceiling color, color of the backside: red.

Colouring and putting together

Colouring and putting together. Ok, now it's time for color ! Please take a closer look to the calculation of the ray (1). It hits three lines: the wall the front and backside of the box.

The grey wall has a white ceiling and a black floor. The boxes backside color attribute results in a red column, however, which does't make it to the top of the screen. Another important job is to sort the different columns and put them togehter in a screen column. The sorting of the column parts depends on its distance from the eye. The procedure visualized:

Working out this procedure for all 320 rays we get the following picture:

Summary

## Summary

- A level consists of one or more sectors. Sectors divide a level in smaller pieces.
- For each sector you have to define room structures (walls, boxes, stairways, doors, ...) by defining lines AND define sector fields (moving areas) with height information to support collision detection and hero movement.
- You have to assign attributes like floor and ceiling color, texture and heights to each wall.
- The Running engine calculates a 3D picture out of the 2D structures using a raycasting algorithm.

Back | Home | Info | Concepts | Workshop | Reference | Next