Cinderfox

Terrain

An isometric tile map can have terrain: real height under its cells — hills that roll, cliffs with rock faces, ramps between tiers, a river stepping down in waterfalls. It is drawn from your own pictures, shaped in the editor with brushes, and your scripts can ask it how high a place is and whether a walker can cross from one cell to the next.

What it is drawn from

A terrain is drawn from a terrain set: a .ron file in your game’s terrain/ folder naming its materials — grass, dirt, sand, stone, water — and the faces shown where the ground drops away.

  • Each material has one to four tops: diamonds the size of a map cell, drawn in the isometric view. A material can also have a height map, a grey diamond saying where it wins when it meets another: white wins.

  • Each material names the face it stands over: rock under grass, a waterfall under water.

  • How a material meets the others is its own blend: how sharp its edge is, how far it wanders, whether it hangs a lip over the face below, and whether it darkens its neighbour along their edge. Nothing about how a trail or a shore looks is built in; it is all in the set.

  • Decals are pictures laid on a cell’s top, mostly see-through: a puddle, scree, flowers. You can place them, or give one a rule and the set lays it by itself — on certain materials, at the foot or the top of a cliff, on a share of the cells.

  • Water says which material’s tops are the surface of a pool, how clear it is at the shore and how deep before you cannot see the bottom, and how wide a line of foam it draws where it meets the ground.

A set looks like this:

TerrainSet(
    materials: [
        (name: "grass", tops: ["terrain/grass_0.png", "terrain/grass_1.png"],
         height: Some("terrain/grass_height.png"), face: "rock",
         blend: (wobble: 0.18, overhang: true)),
        (name: "dirt", tops: ["terrain/dirt_0.png"], face: "rock",
         blend: (sharpness: 3.5, rim: 2, rim_dark: 0.78)),
        (name: "water", tops: ["terrain/water_0.png"], face: "rock"),
    ],
    faces: [
        (name: "rock", lit: ["terrain/rock.png"], shaded: ["terrain/rock_shade.png"], storeys: 4),
    ],
    decals: [
        (name: "scree", pictures: ["terrain/scree.png"],
         rule: Some((on: ["grass", "dirt"], at: CliffFoot, chance: 0.6))),
        (name: "puddle", pictures: ["terrain/puddle.png"]),
    ],
    water: Some((material: "water", shallow: 0.35, opaque: 0.85, deep: 2.0, foam: 0.12)),
)

A set holds up to 16 materials, 4 faces and 8 decals.

Save a picture in the folder and the editor shows the change at once, as it does for any picture.

Adding terrain to a map

Select an isometric map and open the Terrain tab along the bottom. A map with no terrain offers to add some: choose the set and how many cells across and down, and press Add terrain. It starts flat, laid with the set’s first material.

Shaping it

With the tab open and the game stopped, drag on the ground to shape it. A ring shows what the brush will cover, lying on the ground under the pointer.

Tool What it does
Raise, Lower Lift or sink the ground, most at the middle
Flatten Toward the height where the drag began
Level Toward a height you set — Alt-click the ground to take its height
Smooth Ease bumps away; it never pulls across a cliff
Roughen Up or down a little by chance: ground that is not a table
Terrace Cells to flat tiers, with cliffs where tiers meet
Ramp Drag from the bottom to the top: a slope between them
Channel Drag a path: a gully or a stream bed along it, V or U
  • Size, Strength and Edge (hard to soft) set the brush; [ and ] make it smaller and larger.
  • Weld on, the land rolls: the cells around the brush lean to meet it. Off, it is the cliff brush: whole cells move, and its edge is a cliff with a face.
  • Snap rounds the heights a brush moves to a quarter, a half or a whole storey, for neat tiers.
  • A whole drag is one ⌘Z. Escape in the middle of one takes it back.

Show colours the map to help you see it: Heights tints each cell by how high it is; Walking marks each edge as a walker would cross it — green a step, blue a ramp, red a cliff, grey blocked; Folds draws the line each cell’s two triangles meet along.

Dressing it

The tab’s Dress row lays things on the ground you have shaped:

Tool What it does
Paint Brush a material onto the cells
Face Brush a different face onto a cliff — a brick wall in the rock
Decal Brush a decal onto the cells’ tops, or take one off
Water Click a hollow: it fills to the brush’s height, every cell joined to it that dips below. Click it again with Drain on to empty it

Fill above paints a material on every cell at a height or higher: snow on the peaks, grass above the shore. Each is one ⌘Z, as a shaping stroke is.

Standing on it

Give a sprite an OnTerrain component, naming the map and a place on it in cells, and it stands there: lifted to the ground’s height, in front of the ground behind it and behind the terrace in front, and hidden where a cliff is between it and you. A script moves it by changing its place. Turn on its blocks and nothing can walk into its cell — a boulder, a guard. Turn on lying and it lies flat on the ground instead of standing — a shadow, a rug — and the part of it past a cliff’s edge is hidden with the cliff.

Tiles on the map’s own layers stand on the ground too, and a tile set Solid in its tileset blocks walking as it blocks a body. In a y-sorted layer each tile stands on its cell’s front point, its foot, and goes behind the ground only where the ground is nearer than that.

A tile set lying in its tileset — a bridge’s deck, a walkway’s boards — lies flat across its cell instead: whoever stands in the cell is drawn over it.

Objects drawn flat, on real ground. If your objects come from a picture baked flat, with their heights already in their tile offsets, keep them on a map of their own and set its stands on (in the Inspector) to the terrain map. They then go behind its cliffs and terraces, as anything standing there does, without being lifted a second time.

Asking it in a script

The terrain table answers how high a place is, which way it slopes and what it is made of; how a walker crosses from one cell to the next (a step, a ramp, a cliff, blocked, or the edge); which place a tap landed on; where a place is drawn; and whether a place is under water, and how deep. A script can also close a cell (a gate shut) or switch a bridge off (a bridge snapped). Every call is in the Lua reference.