Skip to content
Syyrion edited this page Feb 22, 2023 · 8 revisions

A guide to how walls are positioned and moved.

Note that the descriptions here do not account for transformations as they can completely change the behavior of this system.

Positioning

The four verticies of the walls are referred to as V0, V1, V2, and V3.

The area where a wall can exist is always bound by two angles and two limits.

Leading Edge | Line (V0, V1)

The leading edge is always at the exact position of the wall i.e. the radial distance of points V0 or V1 (they're always equal).

Side Edges | Line (V0, V3) and Line (V1, V2)

The two side edges of a wall always coincide with a radial axis. The line (V0, V3) always coincides with the radial axis defined by the origin angle, and the line (V1, V2) always coincides with the radial axis defined by the extent angle.

Rear Edge | Line (V2, V3)

The position of the rear edge is defined by both the position and thickness. Its position is the wall's position plus or minus the thickness. Whether it's plus or minus depends on where the origin limit is placed and is explained below.

Thickness

Thickness can be thought of as a 1D vector along a radial axis that always points towards the origin limit. The user can only specify the magnitude of this vector, but it's direction is determined automatically. However, the vector's direction can be manually flipped by inputting a negative thickness value.

Culling

If the leading or trailing edge of a wall exceeds the bounds of the origin or extent limits, their positions are set equal to the nearest limit. This has the effect of "cutting off" parts of the wall that are out of bounds.

Movement

A wall will always start at the origin limit (unless otherwise specified) and move towards the extent limit. If its position exceeds the bounds of innerlimit - |thickness| < position < outerlimit + |thickness|, then it is automatically deleted. (The variable innerlimit is the value of the smaller limit and the variable outerlimit is the value of the larger limit.)

Negative Speeds

If the wall has a negative speed, it will move in the reverse direction, but still spawns at the origin limit. However this usually isn't desireable as the wall will spawn at the origin limit and immediately go out of bounds causing it to never appear. A better method to create backwards moving walls is to call DualLimit:swap() to switch the locations of the the limits which reverses the "forward" direction.

IMPORTANT: The position parameter of a wall always inherits its value from the current layer's origin limit parameter, NOT the previous layer's position like most other parameters. This has the effect of having walls automatically know where to start their movement when spawned even if the origin limit is changed.

Accessing Wall Instances

Every layer contains a unique table which stores wall instances. This table can be assessed with PolyWall.W. However it usually isn't recommended to try to find wall instances using this table as using any wall creation function (wall, sWall, nWall, dWall) with a <depth> of zero will return a reference to the wall instance that can be stored in a variable. These wall instances are primitive layers which only store information needed for walls to function. They are in ways similar to layers in that they inherit values, but they cannot create layers or walls and do not have a MockPlayer extension class.

Examples
Modifying a wall's parameters after creation.

local wall, key = PolyWall:sWall() -- Create a wall.
wall.vertex:chset(255, 255, 255, 255) -- Set its color to white.
print(key.K) -- prints the CW handle.

This can be shortened to one line:

PolyWall:sWall().vertex:chset(255, 255, 255, 255)

Remember that you can also immediately initialize walls with parameters upon creation. See PolyWall.

Cheat Sheet

A summary diagram of positioning and movement.