A puzzlescript file is divided into 8 sections:
Objects can be placed on different layers:
Background
Target
Player, Wall, Crate
The main purpose of layers is in resolving movements: two objects on the same layer cannot coexist in a single cell. The order of layers also determines in what order things are drawn: from the lowest layer (the first defined) to the highest (last defined) one.
Background = Background1 or Background2
in the legend, you can have several tile types on the background layer. Every tile must have a background tile. If you don't specify one explicitly for a tile, it is inferred based on what background tiles are on the level it's in.
As objects can overflow from the cells that contain them, it is often necessary to control the order in which objects are rendered to avoid one object to overdraw another object in a nearby cell. This is achieved by separating the collision layers into layer groups. (This feature only affects rendering, not collision detection.)
Objects in (the visible part of) the level are rendered in the order defined by these rules:
You use a --
line to separate layer groups. so, for instance, if you want to make a pseudo-3D effect with background tiles filling their cells, characters and walls that overflow their cells upward, and shadows under the characters and walls that overflow upward and leftward, you could have a collision layer definition like this:
Background
Shadows
--
Character, Wall
That way, you make sure that a shadow will not overdraw a character or wall in the cell above or left of the thing that casts the shadow.
The default cell ordering is not always what you want, so you can redefine it for each layer group. To do so, you add two characters after the separation line. These characters can be ^
(upward), v
(downward), >
(rightward), or <
(leftward). The direction defined by the first character is used first, and when a (horizontal or vertical) line along that direction is filled, the direction defined by the second character is used for a new line, parallel to the former. Hence, the default group separator --
is actually equivalent to -->v
.
Tip: if you want to make a group separator look nicer, you can add --
at the end, like that for instance: --^>--
.
The characters |
(default vertical direction) and -
(default horizontal direction) can also be used. They are currently equivalent to v
and >
respectively, but future Pattern:Script versions might provide a preamble option to define the default directions. A typical use of these characters is to switch for a vertical-first rendering with a group separator like --|-
.