The tile language · composing

Composing a tile

Composition is how elements share one tile. Rocks sit bedded in the ground, grass grows right up to them and parts around them, bare earth shows between, and every tile meets its neighbour at the same edge level. The example on this page is a meadow: rocks, grass and bare earth on one tile, printed as one piece with no supports.

Sizes
any; the meadow here is 2×2
Mix
about 80% grass, 20% bare earth counting ground under rocks; 6–9 rocks per 2×2
Printing
no supports; one watertight body
Bases
DungeonBlocks or OpenLOCK
Words used on this page
solid
A thing that stands on the ground: a rock, tree, wall or cliff.
surface
An element that covers ground: bare ground, dirt or grass.
footprint
The outline where a solid meets the ground. Nothing grows inside it.
bare earth
Ground with no grass on it, including the ground under rocks.
apron
A patch of bare earth on one side of a rock, downstream (a wake) or to the side (a scour).
flow
The direction the grass blades lean, which wanders across the tile and parts round rocks.
edge level
The height, 3.4 mm, at which ground meets every tile edge, so tiles butt with no step.
A 2x2 meadow tile: grass flowing around grey rocks and patches of bare earth
The meadow below, 2×2, seed 1: elements/demo/meadow.dtile.

What it looks like

The rocks belong to the ground. Each one is bedded into the soil on every side, so on a slope the uphill side is buried and the downhill side shows no gap. Every rock's top stands clearly above the grass around it, so no rock is swallowed.

The grass treats a rock as an obstacle. Its flow parts upstream of the rock and joins again behind it, the way water runs round a stone. Most rocks have grass right up to them, pressed against the stone and a little lower at its foot. About one rock in three has a patch of bare earth on one side: usually a wake downstream, sometimes a scour to the side. No rock sits in a ring of bare ground.

Bare earth covers about a fifth of the tile, counting the ground under the rocks. It comes as a few natural-size patches in the low ground, not as one big bald area. Grass stays the main cover.

At the tile edge the ground comes down to the standard edge level, so a meadow tile meets any other ground or grass tile with no step.

Using it in a tile

A tile is a short document that lists elements in a stack. The stack is built in the order it is listed, so grass grows round the solids (rocks, trees, walls, cliffs) listed above it. A meadow looks like this:

dharmatiles version="1.0.0"

use "parts/grass" lawn

tile size="2x2" seed=1 {
    stack {
        base
        dirt                                         // the ground, and the bare earth between the grass
        scatter perSquare=2 {                       // about 8 rocks on a 2×2
            rock size="2dmm .. 10dmm" shape=angular buried="30%"
        }
        lawn cover="80%"                             // grass over 80% of the ground; it grows round the rocks
    }
}

This is elements/demo/meadow.dtile, the tile in the picture above. A tile divided by a path or a shore uses a line and a region, and each element acts at= its region; see the path example on the language page.

Specification

Controls

Composition has no look of its own in the tile language. It is controlled by the words every element shares. These are the ones that decide how elements meet.

ControlValuesDefaultEffect
stack orderthe order elements are listed—Built in the order listed: each entry stands on the terrain laid so far. Land bodies are laid in order, each the higher of what is below it and its own top; water is built where it is listed: rocks and reeds listed before it stand in it and get ripple rings, and grass listed after it sees its shore.
at=a region, a line, an edge or edge path, a point ("(0.5sq, 0.5sq)", counted from the north-west corner), or foot(cliff)whole tileWhere the element goes. A region is filled, a line is followed (a path, a wall), a point is where one thing stands, and foot(cliff) is the band at the foot of that kind of solid, where scatters gather. Footprints are kept inside the tile and clear of other solids.
grass coverpercent (a plain fraction)100%Share of the ground grassed over. A meadow uses about 80%.
scatter count / perSquarenumber—How many solids. The meadow uses 6–9 rocks on a 2×2.
rock buriedpercent (a plain fraction)—How much of each rock is under the ground.
regionboundedBy lines, fill points—Divides the tile, like a paint bucket: name the lines, drop fill points.

How rocks and grass meet is fixed and has no control: rock tops stand at least max(1.5 mm, 0.45 × rock height) above the grass; grass is half height at a rock's face, back to full height 1.2 mm out; about 35% of rocks get an apron; bare earth is filled to 20% with natural-size patches. The full language is on the language page.

Heights

NameHeight above the baseUsed for
$dirtEdgeHeight3.4dmmWhere dirt meets every tile edge.
$groundHeight5dmmOpen land: the library's grass and soil.
$waterSurfaceHeight2.6dmmThe calm water surface beside a shore.
$wallHeight33.1dmmThe DungeonBlocks wall top.

Every tile gets these, and the others in library/parts/heights.dtile, as $ names without a use line. A tile's own let adds names and override replaces a $ name.

Edges and joining tiles

Every tile obeys one edge contract, so any two tiles butt with no step:

The full contract is on the tile system page. It is one file, library/parts/edges.dtile, that every tile uses.

Rules

What this element always does. A change to one of these is a change to the element.

Printing and painting

The full printing rules are on the printing page.

How it is made

The program plans the stack by what each element reads and writes, in the order it is listed: surfaces first, then the lift, then solids, with what grows round solids listed after them. It refuses (dt::order) what the listed order cannot satisfy, never reorders it.

  1. Surfaces. Dirt is the ground; floors (flagstones, planks) are laid on it. A later land body is the higher of what is below it and its own top.
  2. Solids. Rocks, trees, walls and cliffs claim their footprints and are bedded into the ground, kept inside the tile and clear of each other.
  3. Growth. Grass and reeds read the footprints: no blade roots inside one, blades stop just inside a rock's face, and the flow parts round each solid.
  4. Join and check. Everything is joined with the base into one body, and the printability gate checks it.

The code: crates/dt-eval/src/plan.rs.