|< How to create an adventure||Index||Inventory & dialog layout >|
A scene represents the world the player can interact with. Usually, this world has three dimensions (3D: width/x, height/y, and depth/z), but the scene on the computer screen has only two (2D: width and height). The third dimension (depth) is an illusion that is created by things becoming smaller to the rear and objects in the front overlapping objects behind them. The following explains, how scenes in ADePT create this illusion of depth and how the player character virtually moves through a 3D scene.
Since the scene is 2D, all shapes and images as well as their positions are located in the two dimensions width and height. Also, all user interactions with the mouse are located in the x/y-plane of the screen. Depth information is only used internally when drawing a scene to determine the overlapping of regions and the position, size, and speed of the player character.
A scene consists of a list of regions, which may include one or several characters. All of these contain information for the 2D appearence and the 3D illusion of the scene.
The visual and interactive appearence of a scene is located on the x/y-plane. The scene itself has a size and an offset that locates the scene in the scene area. The background image of the scene, the image of a region and all of the different images of a character are all displayed on the screen without any transformation into the third dimension. Finally, the position and the shape of a region are defined only for the x/y-plane, too.
The overlapping of regions is determined by ordering them from the front to the back. When painting a scene, first the background colour and the background image of the scene are used. Then the regions are drawn from the back to the front and so the images of regions in the front overlap the ones in the back. When the player clicks with the mouse on the scene, the regions are searched from the front to the back to find the first region for which the clicked position lies in its shape. Again, regions in the front hide the ones in the back.
This ordering of the regions is done by mapping their y-position to the z-axis. (If several objects stand on a flat plane, they appear higher, if they are farther away.) Since not all things stand on the ground, the key 'distance' of a region indicates its distance to the ground. Thus, regions are sorted by the lowest point of their shape moved by the distance. For a character, its position (see below) is used. If several regions (including characters) have the same z-position (and only then), they are sorted according to their order in the regions list of the scene.
The position and the orientation of a player character is located in the x/y-plane, because this is where the player clicks to move the character. Its images are located centered on top of this position. The goto-positions of regions are also x/y-coordinates. When a character has to go to a region, the point where the player clicked on this region is often not the position, where the character should go to because the region is located in the x/y-plane, but the position is mapped onto the x/z-plane. Instead, the character goes to the nearest goto-position.
The position of the character and the distances between two positions have to be mapped onto the x/z-plane, where the character should appear to move. This is done internally according to three parameters of the Scene item. The front and back scaling factor determine how large the character images are painted at the bottom and at the top of the scene. (The back scale may be negative, but then the character must be positioned in the positive area and may not cross the line, where the scaling would be zero.) These factors also determine the mapping of distances on the x-axis. The distances on the z-axis are calculated by the perspective, which is the angle of the viewing field. (This angle could also be expressed by the distance of the viewer or camera from the scene.)
It is necessary to calculate the distances to adjust the speed of the walking character to its current position. The speed on the x/z-plane should be constant, but therefore the speed on the x/y-plane has to be adapted to the perspective of the scene. The 'distance' and 'time' keys of the Character item describe the speed of the character if it is walking the x-axis and the scaling factor is 100%. 'Distance' is the distance to go for one step (time-frame) in the animation of the movement of the walking character. 'Time' is the interval of one animation frame.
Finally, we need to restrict the area, where the character may stand and walk. This is done by the 'boundary' key of the scene and its regions. The boundary of the scene is the area, where the character may walk, but the boundary of a region is the area, that this region excludes from the boundary of the scene. Like the character position, the boundaries are located on the x/y-plane. This means that they are already mapped from the x/z-plane to the x/y-plane. (Indeed, the boundary of a region is the mapping of the region to the ground.) The boundary determines the possible positions of the character without taking into account the dimension of the character.
All positions, images, and shapes in a scene are located in the 2D-space of the screen (x/y). Only the position of a character is mapped internally to the x/z-plane to calculate its scaling and walking speed correctly. The boundary of the scene and its regions are mappings from the x/z-plane into the x/y-plane.
Regions are ordered according to their bottom y-position and their distance from the ground. If the character (or another region) changes it position, this order is recalculated and the regions still overlap correctly. Thus, the image of the character will be in front of or behind the image of a region according to its position in front of or behind the region.