libraryextensions/blender/demos/Td.xtl

Td.xtl -- the tower defense pieces of X_eTaL-games, described in X_eTaL as Blender parts (Bpy.xtl): three towers at three levels -- arrow, cannon, frost -- and three creeps -- runner, brute, shield. Each piece stands on a 1 by 1 tile at z 0, its front (and the part that aims) toward -y, a tower's base about 0.8 wide, a creep's about 0.5; flat colors, the frost crystals glowing. Each has its clips: idle (2 s, a loop) for all, fire (0.4 s) for towers, walk (1 s, a loop) and hit (0.3 s) for creeps. A part that moves in a clip hangs in a group (bp:g_roup), so it turns about its own pivot. Import: "td:" u_se< "Td"

source · imports bp: extensions/blender/lib/Bpy.xtl; dg: extensions/digest/lib/Digest.xtl

Colors and keys

wood : Float

value (private) · line 17
wood ← 0.55 0.36 0.2

darkwood : Float

value (private) · line 18
darkwood ← 0.33 0.21 0.12

stone : Float

value (private) · line 19
stone ← 0.62 0.62 0.64

darkstone : Float

value (private) · line 20
darkstone ← 0.42 0.42 0.45

iron : Float

value (private) · line 21
iron ← 0.25 0.25 0.28

black : Float

value (private) · line 22
black ← 0.1 0.1 0.11

red : Float

value (private) · line 23
red ← 0.8 0.12 0.1
Used in: ʰa̲rrow3

brass : Float

value (private) · line 24
brass ← 0.85 0.66 0.25
Used in: ʰc̲annon3

ice : Float

value (private) · line 25
ice ← 0.7 0.88 1.0

silver : Float

value (private) · line 26
silver ← 0.82 0.84 0.88
Used in: ʰf̲rost2

green : Float

value (private) · line 27
green ← 0.35 0.85 0.25
Used in: ʰr̲unner

darkgreen : Float

value (private) · line 28
darkgreen ← 0.18 0.48 0.14
Used in: ʰr̲unner

brown : Float

value (private) · line 29
brown ← 0.55 0.25 0.15
Used in: ʰb̲rute

darkbrown : Float

value (private) · line 30
darkbrown ← 0.3 0.15 0.1
Used in: ʰb̲rute

bone : Float

value (private) · line 31
bone ← 0.9 0.85 0.7
Used in: ʰb̲rute

amber : Float

value (private) · line 32
amber ← 1.0 0.8 0.2
Used in: ʰb̲rute

steel : Float

value (private) · line 33
steel ← 0.35 0.5 0.72
Used in: ʰs̲hield

darksteel : Float

value (private) · line 34
darksteel ← 0.22 0.3 0.42
Used in: ʰs̲hield

cyan : Float

value (private) · line 35
cyan ← 0.4 0.9 1.0
Used in: ʰs̲hield

white : Float

value (private) · line 36
white ← 0.95 0.95 0.95
Used in: ʰr̲unner

flat : Float

value (private) · line 37
flat ← 0.0 0.0 0.0

one : Float

value (private) · line 38
one ← 1.0 1.0 1.0

idle : Float

value (private) · line 44
idle ← 0.0 0.5 1.0 1.5 2.0

sway : Float

value (private) · line 45
sway ← 0.0 1.0 0.0 -1.0 0.0

slow : Float

value (private) · line 46
slow ← 0.0 1.0 2.0

breathe : Float

value (private) · line 47
breathe ← 0.0 1.0 0.0

turn : Float

value (private) · line 48
turn ← 0.0 1.0 2.0

fire : Float

value (private) · line 49
fire ← 0.0 0.08 0.4

hit : Float

value (private) · line 50
hit ← 0.0 0.1 0.3
Used in: ʰb̲odyKeys

kick : Float

value (private) · line 51
kick ← 0.0 1.0 0.0

walk : Float

value (private) · line 52
walk ← 0.0 0.25 0.5 0.75 1.0

stepa : Float

value (private) · line 53
stepa ← 0.0 1.0 0.0 0.0 0.0

stepb : Float

value (private) · line 54
stepb ← 0.0 0.0 0.0 1.0 0.0

bob : Float

value (private) · line 55
bob ← 0.0 1.0 0.0 1.0 0.0
Used in: ʰb̲odyKeys

ʰk̲ey : (Num a, Any c) => (Char, Char, Char, a, a, b, a) -> c -> Char

function (private) · line 59
ʰk̲ey ← { (part, clip, what, rest, delta, times, ks) z →
  n ← t̲ally ks
  (part, clip, what, times, ((n c̲at 3) r̲eshape rest) + ks '× t̲able delta) ᵇᵖk̲eys 0
}

Arrow towers

ʰc̲rossbow : Any a => (Char, Float, Float) -> a -> Char

function (private) · line 67
ʰc̲rossbow ← { (p, x, len) z →
  ((((p c̲at " stock", x c̲at -0.04 0.06, 0.07 c̲at len c̲at 0.07, flat, darkwood, 0.0) ᵇᵖb̲ox 0)) c̲at
    (((p c̲at " limbs", x c̲at (-0.02 − len ÷ 2.0) c̲at 0.07, 0.44 0.05 0.04 × (len ÷ 0.44) c̲at 1.0 1.0, flat, wood, 0.0) ᵇᵖb̲ox 0)) c̲at
    ((p c̲at " bolt", x c̲at (0.02 − len ÷ 2.0) c̲at 0.11, 0.015 0.015 c̲at len × 0.8, 90.0 0.0 0.0, iron, 0.0) ᵇᵖc̲ylinder 0))
}

ʰa̲imKeys : Any a => (Char, Float, Float, Float) -> a -> Char

function (private) · line 74
ʰa̲imKeys ← { (p, at, deg, back) z →
  ((p c̲at " aim", "idle", "rotation", flat, 0.0 0.0 c̲at deg, idle, sway) ʰk̲ey 0) c̲at ((p c̲at " aim", "fire", "location", at, 0.0 c̲at back c̲at 0.0, fire, kick) ʰk̲ey 0)
}

ʰm̲erlons : Any b => (Char, Float, Float, a) -> b -> Char

function (private) · line 79
ʰm̲erlons ← { (p, w, z, rgb) z0 →
  m̲k ← { (n, x, y) z1 → (p c̲at " merlon " c̲at n, x c̲at y c̲at z, 0.14 0.14 0.12, flat, rgb, 0.0) ᵇᵖb̲ox 0 }
  (("1", w, w) m̲k 0) c̲at (("2", 0.0 − w, w) m̲k 0) c̲at (("3", w, 0.0 − w) m̲k 0) c̲at ("4", 0.0 − w, 0.0 − w) m̲k 0
}

ʰa̲rrow1 : Any a => a -> Char

function (private) · line 84
ʰa̲rrow1 ← { z →
  (((ᵇᵖp̲iece "arrow-1") c̲at (("arrow-1 base", 0.0 0.0 0.04, 0.8 0.8 0.08, flat, darkwood, 0.0) ᵇᵖb̲ox 0)) c̲at
    ((("arrow-1 post", 0.0 0.0 0.36, 0.5 0.5 0.56, flat, wood, 0.0) ᵇᵖb̲ox 0) c̲at (("arrow-1 deck", 0.0 0.0 0.68, 0.66 0.66 0.08, flat, darkwood, 0.0) ᵇᵖb̲ox 0)) c̲at
    ((("arrow-1 aim", 0.0 0.0 0.72, flat) ᵇᵖg̲roup 0) c̲at (("arrow-1", 0.0, 0.44) ʰc̲rossbow 0) c̲at ᵇᵖungroup) c̲at
    ("arrow-1", 0.0 0.0 0.72, 12.0, 0.08) ʰa̲imKeys 0)
}
Used in: ˡm̲odel

ʰa̲rrow2 : Any a => a -> Char

function (private) · line 91
ʰa̲rrow2 ← { z →
  (((ᵇᵖp̲iece "arrow-2") c̲at (("arrow-2 base", 0.0 0.0 0.05, 0.8 0.8 0.1, flat, darkstone, 0.0) ᵇᵖb̲ox 0)) c̲at
    ((("arrow-2 tower", 0.0 0.0 0.5, 0.6 0.6 0.8, flat, stone, 0.0) ᵇᵖb̲ox 0) c̲at ("arrow-2", 0.23, 0.96, stone) ʰm̲erlons 0) c̲at
    ((("arrow-2 aim", 0.0 0.0 0.92, flat) ᵇᵖg̲roup 0) c̲at (("arrow-2 left", -0.12, 0.36) ʰc̲rossbow 0) c̲at (("arrow-2 right", 0.12, 0.36) ʰc̲rossbow 0) c̲at ᵇᵖungroup) c̲at
    ("arrow-2", 0.0 0.0 0.92, 12.0, 0.08) ʰa̲imKeys 0)
}
Used in: ˡm̲odel

ʰa̲rrow3 : Any a => a -> Char

function (private) · line 98
ʰa̲rrow3 ← { z →
  t ← (((ᵇᵖp̲iece "arrow-3") c̲at (("arrow-3 base", 0.0 0.0 0.05, 0.8 0.8 0.1, flat, darkstone, 0.0) ᵇᵖb̲ox 0)) c̲at
    ((("arrow-3 tower", 0.0 0.0 0.65, 0.56 0.56 1.1, flat, stone, 0.0) ᵇᵖb̲ox 0) c̲at (("arrow-3 ledge", 0.0 0.0 1.2, 0.66 0.66 0.06, flat, darkstone, 0.0) ᵇᵖb̲ox 0)) c̲at
    (("arrow-3", 0.26, 1.29, stone) ʰm̲erlons 0) c̲at
    ((("arrow-3 aim", 0.0 0.0 1.26, flat) ᵇᵖg̲roup 0) c̲at (("arrow-3 frame", 0.0 -0.02 0.07, 0.16 0.5 0.1, flat, darkwood, 0.0) ᵇᵖb̲ox 0)) c̲at
    (("arrow-3 limbs", 0.0 -0.24 0.1, 0.62 0.06 0.05, flat, wood, 0.0) ᵇᵖb̲ox 0) c̲at (("arrow-3 drum", 0.0 0.12 0.16, 0.08 0.08 0.16, 0.0 90.0 0.0, iron, 0.0) ᵇᵖc̲ylinder 0))
  b̲olt ← { (n, x) z1 → ("arrow-3 bolt " c̲at n, x c̲at -0.12 0.15, 0.015 0.015 0.4, 90.0 0.0 0.0, iron, 0.0) ᵇᵖc̲ylinder 0 }
  ((t c̲at (("1", -0.05) b̲olt 0) c̲at (("2", 0.0) b̲olt 0) c̲at (("3", 0.05) b̲olt 0) c̲at ᵇᵖungroup) c̲at
    ((("arrow-3 banner", -0.26 0.26 1.35, flat) ᵇᵖg̲roup 0) c̲at (("arrow-3 pole", 0.0 0.0 0.25, 0.015 0.015 0.5, flat, iron, 0.0) ᵇᵖc̲ylinder 0)) c̲at
    ((("arrow-3 flag", 0.13 0.0 0.4, 0.24 0.02 0.16, flat, red, 0.0) ᵇᵖb̲ox 0) c̲at ᵇᵖungroup) c̲at
    (("arrow-3", 0.0 0.0 1.26, 10.0, 0.1) ʰa̲imKeys 0) c̲at
    ("arrow-3 banner", "idle", "rotation", flat, 0.0 0.0 25.0, idle, sway) ʰk̲ey 0)
}
Used in: ˡm̲odel

Cannon towers

ʰc̲annon1 : Any a => a -> Char

function (private) · line 114
ʰc̲annon1 ← { z →
  (((ᵇᵖp̲iece "cannon-1") c̲at (("cannon-1 base", 0.0 0.0 0.14, 0.34 0.34 0.28, flat, stone, 0.0) ᵇᵖc̲ylinder 0)) c̲at
    ((("cannon-1 rim", 0.0 0.0 0.28, 0.32 0.03, flat, darkstone, 0.0) ᵇᵖt̲orus 0)) c̲at
    ((("cannon-1 aim", 0.0 0.0 0.28, flat) ᵇᵖg̲roup 0) c̲at (("cannon-1 mount", 0.0 0.0 0.07, 0.22 0.22 0.14, flat, darkwood, 0.0) ᵇᵖb̲ox 0)) c̲at
    ((("cannon-1 barrel", 0.0 -0.16 0.12, 0.07 0.07 0.34, 90.0 0.0 0.0, black, 0.0) ᵇᵖc̲ylinder 0) c̲at (("cannon-1 muzzle", 0.0 -0.33 0.12, 0.07 0.02, 90.0 0.0 0.0, black, 0.0) ᵇᵖt̲orus 0)) c̲at
    ᵇᵖungroup c̲at ("cannon-1", 0.0 0.0 0.28, 8.0, 0.1) ʰa̲imKeys 0)
}
Used in: ˡm̲odel

ʰc̲annon2 : Any a => a -> Char

function (private) · line 122
ʰc̲annon2 ← { z →
  (((ᵇᵖp̲iece "cannon-2") c̲at (("cannon-2 base", 0.0 0.0 0.17, 0.4 0.4 0.34, flat, stone, 0.0) ᵇᵖc̲ylinder 0)) c̲at
    ((("cannon-2 rim", 0.0 0.0 0.34, 0.38 0.035, flat, darkstone, 0.0) ᵇᵖt̲orus 0)) c̲at
    ((("cannon-2 aim", 0.0 0.0 0.34, flat) ᵇᵖg̲roup 0) c̲at (("cannon-2 mount", 0.0 0.02 0.08, 0.28 0.26 0.16, flat, darkwood, 0.0) ᵇᵖb̲ox 0)) c̲at
    ((("cannon-2 barrel", 0.0 -0.22 0.15, 0.08 0.08 0.52, 90.0 0.0 0.0, black, 0.0) ᵇᵖc̲ylinder 0)) c̲at
    ((("cannon-2 band 1", 0.0 -0.1 0.15, 0.085 0.022, 90.0 0.0 0.0, iron, 0.0) ᵇᵖt̲orus 0) c̲at (("cannon-2 band 2", 0.0 -0.42 0.15, 0.085 0.022, 90.0 0.0 0.0, iron, 0.0) ᵇᵖt̲orus 0)) c̲at
    ᵇᵖungroup c̲at ("cannon-2", 0.0 0.0 0.34, 8.0, 0.12) ʰa̲imKeys 0)
}
Used in: ˡm̲odel

ʰc̲annon3 : Any a => a -> Char

function (private) · line 131
ʰc̲annon3 ← { z →
  base ← 6 2 r̲eshape 0.0 0.0  0.4 0.0  0.4 0.1  0.33 0.16  0.31 0.36  0.0 0.36
  t ← (((ᵇᵖp̲iece "cannon-3") c̲at (("cannon-3 base", 0.0 0.0 0.0, base, 16, flat, stone, 0.0) ᵇᵖl̲athe 0)) c̲at
    ((("cannon-3 ring", 0.0 0.0 0.38, 0.3 0.04, flat, brass, 0.0) ᵇᵖt̲orus 0)) c̲at
    (("cannon-3 aim", 0.0 0.0 0.4, flat) ᵇᵖg̲roup 0) c̲at (("cannon-3 dome", 0.0 0.0 0.04, 0.26 0.26 0.18, flat, darkstone, 0.0) ᵇᵖs̲phere 0))
  b̲arrel ← { (n, x) z1 →
    a ← (("cannon-3 barrel " c̲at n, x c̲at -0.26 0.1, 0.06 0.06 0.5, 90.0 0.0 0.0, black, 0.0) ᵇᵖc̲ylinder 0)
    a c̲at (("cannon-3 trim " c̲at n, x c̲at -0.5 0.1, 0.065 0.02, 90.0 0.0 0.0, brass, 0.0) ᵇᵖt̲orus 0)
  }
  withBarrels ← t c̲at (("1", -0.1) b̲arrel 0) c̲at (("2", 0.1) b̲arrel 0) c̲at (("cannon-3 hatch", 0.0 0.05 0.2, 0.08 0.08 0.03, flat, brass, 0.0) ᵇᵖc̲ylinder 0)
  withBarrels c̲at ᵇᵖungroup c̲at ("cannon-3", 0.0 0.0 0.4, 15.0, 0.1) ʰa̲imKeys 0
}
Used in: ˡm̲odel

Frost towers

ʰc̲rystalKeys : (Any a, Any b) => (Char, a, Float) -> b -> Char

function (private) · line 147
ʰc̲rystalKeys ← { (g, at, swell) z →
  ((g, "idle", "rotation", flat, 0.0 0.0 180.0, slow, turn) ʰk̲ey 0) c̲at ((g, "fire", "scale", one, swell c̲at swell c̲at swell, fire, kick) ʰk̲ey 0)
}

ʰf̲rost1 : Any a => a -> Char

function (private) · line 151
ʰf̲rost1 ← { z →
  ped ← 7 2 r̲eshape 0.0 0.0  0.3 0.0  0.3 0.08  0.17 0.14  0.13 0.38  0.2 0.44  0.0 0.44
  (((ᵇᵖp̲iece "frost-1") c̲at (("frost-1 pedestal", 0.0 0.0 0.0, ped, 12, flat, stone, 0.0) ᵇᵖl̲athe 0)) c̲at
    ((("frost-1 aim", 0.0 0.0 0.66, flat) ᵇᵖg̲roup 0) c̲at (("frost-1 crystal", 0.0 0.0 0.0, 0.1 0.1 0.22, flat, ice, 0.4) ᵇᵖo̲ctahedron 0)) c̲at
    ᵇᵖungroup c̲at ("frost-1 aim", 0.0 0.0 0.66, 0.35) ʰc̲rystalKeys 0)
}
Used in: ˡm̲odel

ʰf̲rost2 : Any a => a -> Char

function (private) · line 158
ʰf̲rost2 ← { z →
  ped ← 7 2 r̲eshape 0.0 0.0  0.34 0.0  0.34 0.1  0.2 0.16  0.15 0.55  0.22 0.62  0.0 0.62
  (((ᵇᵖp̲iece "frost-2") c̲at (("frost-2 pedestal", 0.0 0.0 0.0, ped, 12, flat, stone, 0.0) ᵇᵖl̲athe 0)) c̲at
    ((("frost-2 ring", 0.0 0.0 0.72, 0.2 0.022, flat, silver, 0.0) ᵇᵖt̲orus 0)) c̲at
    ((("frost-2 aim", 0.0 0.0 0.86, flat) ᵇᵖg̲roup 0) c̲at (("frost-2 crystal", 0.0 0.0 0.0, 0.1 0.1 0.24, flat, ice, 0.6) ᵇᵖo̲ctahedron 0)) c̲at
    ((("frost-2 shard 1", -0.1 0.0 -0.06, 0.06 0.06 0.15, 0.0 -25.0 0.0, ice, 0.6) ᵇᵖo̲ctahedron 0) c̲at (("frost-2 shard 2", 0.1 0.0 -0.06, 0.06 0.06 0.15, 0.0 25.0 0.0, ice, 0.6) ᵇᵖo̲ctahedron 0)) c̲at
    ((("frost-2 shard 3", 0.0 0.09 -0.08, 0.05 0.05 0.12, 25.0 0.0 0.0, ice, 0.6) ᵇᵖo̲ctahedron 0)) c̲at
    ᵇᵖungroup c̲at ("frost-2 aim", 0.0 0.0 0.86, 0.3) ʰc̲rystalKeys 0)
}
Used in: ˡm̲odel

ʰf̲rost3 : Any a => a -> Char

function (private) · line 168
ʰf̲rost3 ← { z →
  ped ← 7 2 r̲eshape 0.0 0.0  0.38 0.0  0.38 0.1  0.24 0.18  0.17 0.6  0.26 0.68  0.0 0.68
  t ← (((ᵇᵖp̲iece "frost-3") c̲at (("frost-3 pedestal", 0.0 0.0 0.0, ped, 12, flat, stone, 0.0) ᵇᵖl̲athe 0)) c̲at
    (("frost-3 aim", 0.0 0.0 1.0, flat) ᵇᵖg̲roup 0) c̲at (("frost-3 crystal", 0.0 0.0 0.0, 0.13 0.13 0.3, flat, ice, 2.5) ᵇᵖo̲ctahedron 0) c̲at ᵇᵖungroup)
  s̲hard ← { (n, x, y) z1 → ("frost-3 shard " c̲at n, x c̲at y c̲at 0.0, 0.04 0.04 0.09, flat, ice, 1.5) ᵇᵖo̲ctahedron 0 }
  ((t c̲at (("frost-3 shards", 0.0 0.0 0.96, flat) ᵇᵖg̲roup 0) c̲at (("1", 0.26, 0.0) s̲hard 0) c̲at (("2", -0.26, 0.0) s̲hard 0) c̲at (("3", 0.0, 0.26) s̲hard 0) c̲at (("4", 0.0, -0.26) s̲hard 0) c̲at ᵇᵖungroup) c̲at
    (("frost-3 aim", 0.0 0.0 1.0, 0.4) ʰc̲rystalKeys 0) c̲at
    (("frost-3 aim", "idle", "location", 0.0 0.0 1.0, 0.0 0.0 0.05, slow, breathe) ʰk̲ey 0) c̲at
    (("frost-3 shards", "idle", "rotation", flat, 0.0 0.0 -90.0, slow, turn) ʰk̲ey 0) c̲at
    ("frost-3 shards", "fire", "scale", one, 0.6 0.6 0.6, fire, kick) ʰk̲ey 0)
}
Used in: ˡm̲odel

Creeps

ʰb̲odyKeys : Any a => (Char, Float) -> a -> Char

function (private) · line 184
ʰb̲odyKeys ← { (p, at) z →
  b ← p c̲at " body"
  t ← ((b, "idle", "scale", one, 0.0 0.0 0.06, slow, breathe) ʰk̲ey 0) c̲at ((b, "walk", "location", at, 0.0 0.0 0.02, walk, bob) ʰk̲ey 0)
  t c̲at ((b, "hit", "rotation", flat, -20.0 0.0 0.0, hit, kick) ʰk̲ey 0) c̲at ((b, "hit", "scale", one, 0.08 0.08 -0.12, hit, kick) ʰk̲ey 0)
}

ʰf̲oot : Any a => (Char, Float, Float) -> a -> Char

function (private) · line 191
ʰf̲oot ← { (name, at, ks) z → (name, "walk", "location", at, 0.0 0.0 0.05, walk, ks) ʰk̲ey 0 }

ʰr̲unner : Any a => a -> Char

function (private) · line 193
ʰr̲unner ← { z →
  v ← 8 3 r̲eshape -0.2 -0.25 0.0  0.2 -0.25 0.0  0.2 0.25 0.0  -0.2 0.25 0.0  -0.2 0.25 0.24  0.2 0.25 0.24  -0.2 -0.25 0.06  0.2 -0.25 0.06
  f ← 6 4 r̲eshape 0 1 2 3  3 2 5 4  7 6 4 5  0 1 7 6  0 6 4 3  1 2 5 7
  t ← (ᵇᵖp̲iece "runner") c̲at (("runner body", 0.0 0.0 0.12, flat) ᵇᵖg̲roup 0) c̲at (("runner shell", 0.0 0.0 0.0, v, f, flat, green, 0.0) ᵇᵖm̲esh 0)
  e̲ye ← { (n, x) z1 → (("runner eye " c̲at n, x c̲at -0.16 0.12, 0.055 0.055 0.055, flat, white, 0.0) ᵇᵖs̲phere 0) c̲at (("runner pupil " c̲at n, x c̲at -0.205 0.125, 0.025 0.025 0.025, flat, black, 0.0) ᵇᵖs̲phere 0) }
  withEyes ← t c̲at (("1", -0.09) e̲ye 0) c̲at (("2", 0.09) e̲ye 0) c̲at ᵇᵖungroup
  l̲eg ← { (n, at) z1 → ("runner foot " c̲at n, at, 0.07 0.07 0.14, flat, darkgreen, 0.0) ᵇᵖb̲ox 0 }
  ((withEyes c̲at (("1", -0.14 -0.16 0.07) l̲eg 0) c̲at (("2", 0.14 -0.16 0.07) l̲eg 0) c̲at (("3", -0.14 0.16 0.07) l̲eg 0) c̲at (("4", 0.14 0.16 0.07) l̲eg 0)) c̲at
    (("runner", 0.0 0.0 0.12) ʰb̲odyKeys 0) c̲at
    ((("runner foot 1", -0.14 -0.16 0.07, stepa) ʰf̲oot 0) c̲at (("runner foot 4", 0.14 0.16 0.07, stepa) ʰf̲oot 0)) c̲at
    (("runner foot 2", 0.14 -0.16 0.07, stepb) ʰf̲oot 0) c̲at ("runner foot 3", -0.14 0.16 0.07, stepb) ʰf̲oot 0)
}
Used in: ˡm̲odel

ʰb̲rute : Any a => a -> Char

function (private) · line 206
ʰb̲rute ← { z →
  (((ᵇᵖp̲iece "brute") c̲at (("brute body", 0.0 0.0 0.2, flat) ᵇᵖg̲roup 0) c̲at (("brute torso", 0.0 0.02 0.18, 0.5 0.42 0.36, flat, brown, 0.0) ᵇᵖb̲ox 0)) c̲at
    ((("brute head", 0.0 -0.26 0.22, 0.3 0.2 0.22, flat, darkbrown + 0.15, 0.0) ᵇᵖb̲ox 0)) c̲at
    ((("brute horn 1", -0.12 -0.3 0.4, 0.05 0.0 0.2, 0.0 -25.0 0.0, bone, 0.0) ᵇᵖc̲one 0) c̲at (("brute horn 2", 0.12 -0.3 0.4, 0.05 0.0 0.2, 0.0 25.0 0.0, bone, 0.0) ᵇᵖc̲one 0)) c̲at
    ((("brute eye 1", -0.07 -0.365 0.25, 0.03 0.03 0.03, flat, amber, 0.3) ᵇᵖs̲phere 0) c̲at (("brute eye 2", 0.07 -0.365 0.25, 0.03 0.03 0.03, flat, amber, 0.3) ᵇᵖs̲phere 0) c̲at ᵇᵖungroup) c̲at
    ((("brute foot 1", -0.15 0.0 0.1, 0.16 0.22 0.2, flat, darkbrown, 0.0) ᵇᵖb̲ox 0) c̲at (("brute foot 2", 0.15 0.0 0.1, 0.16 0.22 0.2, flat, darkbrown, 0.0) ᵇᵖb̲ox 0)) c̲at
    (("brute", 0.0 0.0 0.2) ʰb̲odyKeys 0) c̲at
    (("brute body", "walk", "rotation", flat, 0.0 4.0 0.0, walk, sway) ʰk̲ey 0) c̲at
    (("brute foot 1", -0.15 0.0 0.1, stepa) ʰf̲oot 0) c̲at ("brute foot 2", 0.15 0.0 0.1, stepb) ʰf̲oot 0)
}
Used in: ˡm̲odel

ʰs̲hield : Any a => a -> Char

function (private) · line 217
ʰs̲hield ← { z →
  dome ← 7 2 r̲eshape 0.0 0.0  0.27 0.0  0.26 0.08  0.235 0.14  0.19 0.2  0.12 0.245  0.0 0.26
  t ← (ᵇᵖp̲iece "shield") c̲at (("shield body", 0.0 0.0 0.06, flat) ᵇᵖg̲roup 0) c̲at (("shield shell", 0.0 0.0 0.0, dome, 16, flat, steel, 0.0) ᵇᵖl̲athe 0)
  p̲late ← { (n, at, deg) z1 → ("shield plate " c̲at n, at, 0.2 0.04 0.1, 0.0 0.0 c̲at deg, darksteel, 0.0) ᵇᵖb̲ox 0 }
  withPlates ← ((t c̲at (("1", 0.0 -0.255 0.06, 0.0) p̲late 0) c̲at (("2", 0.0 0.255 0.06, 0.0) p̲late 0) c̲at (("3", -0.255 0.0 0.06, 90.0) p̲late 0) c̲at (("4", 0.255 0.0 0.06, 90.0) p̲late 0)) c̲at
    (("shield eye 1", -0.06 -0.215 0.15, 0.03 0.03 0.03, flat, cyan, 0.5) ᵇᵖs̲phere 0) c̲at (("shield eye 2", 0.06 -0.215 0.15, 0.03 0.03 0.03, flat, cyan, 0.5) ᵇᵖs̲phere 0) c̲at ᵇᵖungroup)
  f̲t ← { (n, at) z1 → ("shield foot " c̲at n, at, 0.05 0.05 0.06, flat, darksteel, 0.0) ᵇᵖc̲ylinder 0 }
  ((withPlates c̲at (("1", -0.15 -0.15 0.03) f̲t 0) c̲at (("2", 0.15 -0.15 0.03) f̲t 0) c̲at (("3", -0.15 0.15 0.03) f̲t 0) c̲at (("4", 0.15 0.15 0.03) f̲t 0)) c̲at
    (("shield", 0.0 0.0 0.06) ʰb̲odyKeys 0) c̲at
    ((("shield foot 1", -0.15 -0.15 0.03, stepa) ʰf̲oot 0) c̲at (("shield foot 4", 0.15 0.15 0.03, stepa) ʰf̲oot 0)) c̲at
    (("shield foot 2", 0.15 -0.15 0.03, stepb) ʰf̲oot 0) c̲at ("shield foot 3", -0.15 0.15 0.03, stepb) ʰf̲oot 0)
}
Used in: ˡm̲odel

The pieces

ˡnames : Char

value · line 234

the twelve pieces' names, as X_eTaL-games asked for them, a space between: the files are NAME.glb

ˡnames ← "arrow-1 arrow-2 arrow-3 cannon-1 cannon-2 cannon-3 frost-1 frost-2 frost-3 runner brute shield"
Used in: ˡclips, ˡshow

ˡm̲odel : Char -> Char

function · line 238

td:m_odel name: Python making the piece NAME (one of td:names) and keying its clips; "" for another name

ˡm̲odel ← { name →
  name m̲atch "arrow-1" ? ʰa̲rrow1 0
  name m̲atch "arrow-2" ? ʰa̲rrow2 0
  name m̲atch "arrow-3" ? ʰa̲rrow3 0
  name m̲atch "cannon-1" ? ʰc̲annon1 0
  name m̲atch "cannon-2" ? ʰc̲annon2 0
  name m̲atch "cannon-3" ? ʰc̲annon3 0
  name m̲atch "frost-1" ? ʰf̲rost1 0
  name m̲atch "frost-2" ? ʰf̲rost2 0
  name m̲atch "frost-3" ? ʰf̲rost3 0
  name m̲atch "runner" ? ʰr̲unner 0
  name m̲atch "brute" ? ʰb̲rute 0
  name m̲atch "shield" ? ʰs̲hield 0
  ""
}
Used in: ˡe̲xport

ˡmeshMost : Int

value · line 256

the most triangles a piece's low-poly mesh (NAME-mesh.toml) has: the ask's "a few hundred"; the cannons, over it, are decimated

ˡmeshMost ← 500

ˡe̲xport : Char -> Char

function · line 262

td:e_xport name: Python making the piece NAME, writing it as out/NAME.glb with its clips, reading its clips back into out/NAME-clips.txt, and writing its low-poly mesh at rest as out/NAME-mesh.toml (bp:m_eshToml)

ˡe̲xport ← { name → (ˡm̲odel name) c̲at (ᵇᵖe̲xportPiece name) c̲at (ᵇᵖc̲lips name) c̲at (name, ˡmeshMost) ᵇᵖm̲eshToml 0 }
Used in: ˡall

ˡclips : Char

value · line 266

td:clips: Python joining the pieces' clip files into out/clips.txt, each piece's name, then its clips

ˡclips ← "with open(os.path.join(out, \"clips.txt\"), \"w\") as f:\n    for n in \"" c̲at ˡnames c̲at "\".split():\n        f.write(n + \"\\n\" + open(os.path.join(out, n + \"-clips.txt\")).read())\n"
Used in: ˡall

ˡall : Char

value · line 270

td:all: Python making every piece and writing its .glb (td:e_xport), then out/clips.txt

ˡall ← (ˡe̲xport "arrow-1") c̲at (ˡe̲xport "arrow-2") c̲at (ˡe̲xport "arrow-3") c̲at (ˡe̲xport "cannon-1") c̲at (ˡe̲xport "cannon-2") c̲at (ˡe̲xport "cannon-3") c̲at (ˡe̲xport "frost-1") c̲at (ˡe̲xport "frost-2") c̲at (ˡe̲xport "frost-3") c̲at (ˡe̲xport "runner") c̲at (ˡe̲xport "brute") c̲at (ˡe̲xport "shield") c̲at ˡclips
Used in: script, _

Showing them

ˡshow : Char

value · line 281

td:show: Python helpers for showing the pieces: td_stills renders each alone; td_closeups shows them one after another, close, each turning once round and playing its clips, captioned; td_film lines them up (towers by kind and level, the creeps in a fourth column), each turning once round, playing idle, then fire or walk. A video keeps each part's rest on a track under its clips (Blender's NLA puts a property no playing strip keys at zero, not at its rest).

ˡshow ← "td_names = \"" c̲at ˡnames c̲at "\".split()\ntd_creeps = [\"runner\", \"brute\", \"shield\"]\ntd_saved = {}\ntd_seconds = {\"idle\": 2.0, \"walk\": 1.0, \"fire\": 0.4, \"hit\": 0.3}\n\ndef td_parts():\n    return [c for n in td_names for c in bpy.data.objects[n].children_recursive]\n\ndef td_prepare():\n    if td_saved:\n        return\n    for p in td_parts():\n        ad = p.animation_data\n        clips = [(t.name, t.strips[0].action) for t in ad.nla_tracks if len(t.strips)] if ad else []\n        td_saved[p.name] = (tuple(p.location), tuple(p.rotation_euler), tuple(p.scale), clips)\n\ndef td_reset():\n    td_prepare()\n    for o in [o for o in scene.objects if o.name.startswith(\"closeup \")]:\n        bpy.data.objects.remove(o)\n    for n in td_names:\n        o = bpy.data.objects[n]\n        o.animation_data_clear()\n        o.hide_render = False\n        o.location = (0.0, 0.0, 0.0)\n        o.rotation_euler = (0.0, 0.0, 0.0)\n    for p in td_parts():\n        loc, rot, scale, clips = td_saved[p.name]\n        p.hide_render = False\n        if not clips:\n            p.animation_data_clear()\n            continue\n        ad = p.animation_data\n        ad.action = None\n        while len(ad.nla_tracks):\n            ad.nla_tracks.remove(ad.nla_tracks[0])\n        p.location, p.rotation_euler, p.scale = loc, rot, scale\n        rest = bpy.data.actions.new(p.name + \" rest\")\n        ad.action = rest\n        for path in (\"location\", \"rotation_euler\", \"scale\"):\n            p.keyframe_insert(data_path=path, frame=1)\n        ad.action = None\n        base = ad.nla_tracks.new()\n        base.name = \"rest\"\n        base.strips.new(\"rest\", 1, rest).extrapolation = \"HOLD\"\n\ndef td_frames(clip):\n    return int(round(td_seconds[clip] * scene.render.fps))\n\ndef td_play(n, clip, starts):\n    for p in bpy.data.objects[n].children_recursive:\n        for name, act in td_saved[p.name][3]:\n            if name != clip:\n                continue\n            ad = p.animation_data\n            tr = ad.nla_tracks.get(clip)\n            if tr is None:\n                tr = ad.nla_tracks.new()\n                tr.name = clip\n            for s0 in starts:\n                tr.strips.new(clip + \" \" + str(s0), int(s0), act).extrapolation = \"NOTHING\"\n\ndef td_loop(clip, a, b):\n    k = td_frames(clip)\n    return range(a, b - k + 2, k)\n\ndef td_turn(o, a, b):\n    o.rotation_euler = (0.0, 0.0, 0.0)\n    o.keyframe_insert(\"rotation_euler\", index=2, frame=a)\n    o.rotation_euler = (0.0, 0.0, 2 * math.pi)\n    o.keyframe_insert(\"rotation_euler\", index=2, frame=b + 1)\n\ndef td_shown(x, a, b):\n    if a > 1:\n        x.hide_render = True\n        x.keyframe_insert(\"hide_render\", frame=a - 1)\n    x.hide_render = False\n    x.keyframe_insert(\"hide_render\", frame=a)\n    x.hide_render = True\n    x.keyframe_insert(\"hide_render\", frame=b + 1)\n\ndef td_hide(o, h):\n    o.hide_render = h\n    for c in o.children_recursive:\n        c.hide_render = h\n\ndef td_camera(at, scale, dist, up, side):\n    aim = bpy.data.objects.new(\"aim\", None)\n    aim.location = at\n    scene.collection.objects.link(aim)\n    cam = bpy.data.objects.new(\"camera\", bpy.data.cameras.new(\"camera\"))\n    cam.data.type = \"ORTHO\"\n    cam.data.ortho_scale = scale\n    cam.data.clip_end = 1000\n    a, e = math.radians(side), math.radians(up)\n    cam.location = (at[0] + dist * math.sin(a) * math.cos(e), at[1] - dist * math.cos(a) * math.cos(e), at[2] + dist * math.sin(e))\n    look = cam.constraints.new(\"TRACK_TO\")\n    look.target = aim\n    look.track_axis = \"TRACK_NEGATIVE_Z\"\n    look.up_axis = \"UP_Y\"\n    scene.collection.objects.link(cam)\n    scene.camera = cam\n    return cam\n\ndef td_text(name, body, size, rgb):\n    c = bpy.data.curves.new(name, type=\"FONT\")\n    c.body = body\n    c.size = size\n    t = bpy.data.objects.new(name, c)\n    scene.collection.objects.link(t)\n    t.data.materials.append(material(name, rgb, 0.6))\n    return t\n\ndef td_height(o):\n    import mathutils\n    bpy.context.view_layer.update()\n    return max((c.matrix_world @ mathutils.Vector(k)).z for c in o.children_recursive if c.type == \"MESH\" for k in c.bound_box)\n\ndef td_render_settings(w, h):\n    scene.render.engine = \"BLENDER_EEVEE\"\n    scene.view_settings.view_transform = \"Standard\"\n    scene.render.use_freestyle = False\n    scene.render.resolution_x = w\n    scene.render.resolution_y = h\n    scene.render.resolution_percentage = 100\n\ndef td_stills(size):\n    td_prepare()\n    td_render_settings(size, size)\n    scene.render.film_transparent = True\n    td_camera((0.0, 0.0, 0.85), 2.3, 8.0, 25, 25)\n    scene.render.image_settings.media_type = \"IMAGE\"\n    scene.render.image_settings.file_format = \"PNG\"\n    scene.render.image_settings.color_mode = \"RGBA\"\n    scene.frame_set(0)\n    for n in td_names:\n        for m in td_names:\n            td_hide(bpy.data.objects[m], m != n)\n        scene.render.filepath = os.path.join(out, n + \".png\")\n        bpy.ops.render.render(write_still=True)\n    for m in td_names:\n        td_hide(bpy.data.objects[m], False)\n    scene.render.film_transparent = False\n\ndef td_radius(o):\n    import mathutils\n    bpy.context.view_layer.update()\n    return max(math.hypot(*(c.matrix_world @ mathutils.Vector(k)).xy) for c in o.children_recursive if c.type == \"MESH\" for k in c.bound_box)\n\ndef td_join(frames, cols, size, path):\n    import numpy as np\n    rows = (len(frames) + cols - 1) // cols\n    sheet = np.zeros((rows * size, cols * size, 4), dtype=np.float32)\n    for i, f in enumerate(frames):\n        img = bpy.data.images.load(f)\n        a = np.array(img.pixels[:], dtype=np.float32).reshape(size, size, 4)\n        r, c = divmod(i, cols)\n        y = (rows - 1 - r) * size\n        sheet[y:y + size, c * size:(c + 1) * size] = a\n        bpy.data.images.remove(img)\n    out = bpy.data.images.new(os.path.basename(path), cols * size, rows * size, alpha=True)\n    out.pixels = sheet.ravel()\n    out.filepath_raw = path\n    out.file_format = \"PNG\"\n    out.save()\n    bpy.data.images.remove(out)\n\ntd_map_px = 32.0 * math.sqrt(2.0)\ntd_map_up = 30\ntd_map_anchor = 82 / 96\n\ndef td_spin(o, size, angles, prefix):\n    o.animation_data_clear()\n    for k, a in enumerate(angles):\n        o.rotation_euler = (0.0, 0.0, math.radians(a))\n        o.keyframe_insert(\"rotation_euler\", index=2, frame=k + 1)\n    scene.frame_start = 1\n    scene.frame_end = len(angles)\n    td_render_settings(size, size)\n    scene.render.filepath = prefix\n    bpy.ops.render.render(animation=True)\n    o.animation_data_clear()\n    o.rotation_euler = (0.0, 0.0, 0.0)\n    return [prefix + \"%04d.png\" % (k + 1) for k in range(len(angles))]\n\ndef td_sheets(turn, mapsize):\n    import tempfile\n    td_prepare()\n    scene.frame_set(0)\n    muted = []\n    for p in td_parts():\n        if p.animation_data:\n            for t in p.animation_data.nla_tracks:\n                if not t.mute:\n                    t.mute = True\n                    muted.append(t)\n    scene.render.film_transparent = True\n    scene.render.image_settings.media_type = \"IMAGE\"\n    scene.render.image_settings.file_format = \"PNG\"\n    scene.render.image_settings.color_mode = \"RGBA\"\n    tmp = tempfile.mkdtemp()\n    for n in td_names:\n        o = bpy.data.objects[n]\n        for m in td_names:\n            td_hide(bpy.data.objects[m], m != n)\n        top, r = td_height(o), td_radius(o)\n        td_camera((0.0, 0.0, top * 0.5), 1.12 * max(2 * r, top * 0.95 + 2 * r * math.sin(math.radians(20))), 10.0, 20, 0)\n        frames = td_spin(o, turn, [22.5 * k for k in range(16)], os.path.join(tmp, n + \"-turn-\"))\n        td_join(frames, 4, turn, os.path.join(out, n + \"-turn.png\"))\n        cam = td_camera((0.0, 0.0, 0.0), 96 / td_map_px, 10.0, td_map_up, 0)\n        cam.data.shift_y = td_map_anchor - 0.5\n        frames = td_spin(o, mapsize, [90 - 45 * k for k in range(8)], os.path.join(tmp, n + \"-map-\"))\n        td_join(frames, 8, mapsize, os.path.join(out, n + \"-map.png\"))\n    for m in td_names:\n        td_hide(bpy.data.objects[m], False)\n    for t in muted:\n        t.mute = False\n    scene.render.film_transparent = False\n\ndef td_closeups(w, h, seg):\n    td_reset()\n    td_render_settings(w, h)\n    scene.frame_start = 1\n    scene.frame_end = seg * len(td_names)\n    cam = td_camera((0.0, 0.0, 0.75), 3.4, 8.0, 22, 25)\n    aim = cam.constraints[0].target\n    for i, n in enumerate(td_names):\n        a = i * seg + 1\n        b = a + seg - 1\n        o = bpy.data.objects[n]\n        top = td_height(o)\n        s = max(1.4, top * 1.25 + 0.3) * 16 / 9\n        for f in (a, b):\n            aim.location = (0.0, 0.0, top * 0.45)\n            aim.keyframe_insert(\"location\", frame=f)\n            cam.data.ortho_scale = s\n            cam.data.keyframe_insert(\"ortho_scale\", frame=f)\n        for x in [o] + list(o.children_recursive):\n            td_shown(x, a, b)\n        td_turn(o, a, b)\n        half = a + seg // 2 - 1\n        td_play(n, \"idle\", td_loop(\"idle\", a, half))\n        if n in td_creeps:\n            third = (b - half) // 2\n            phases = [(\"idle\", a, half), (\"walk\", half + 1, half + third), (\"hit\", half + third + 1, b)]\n            td_play(n, \"walk\", td_loop(\"walk\", half + 1, half + third))\n            td_play(n, \"hit\", range(half + third + 3, b - td_frames(\"hit\") + 1, td_frames(\"hit\") + 10))\n        else:\n            phases = [(\"idle\", a, half), (\"fire\", half + 1, b)]\n            td_play(n, \"fire\", range(half + 3, b - td_frames(\"fire\") + 1, td_frames(\"fire\") + 10))\n        for clip, pa, pb in phases:\n            t = td_text(\"closeup \" + n + \" \" + clip, n + \"   \" + clip, 0.05 * s, (1.0, 1.0, 1.0))\n            t.parent = cam\n            t.location = (-0.46 * s, 0.22 * s, -2.0)\n            td_shown(t, pa, pb)\n\ndef td_place(n):\n    if n in td_creeps:\n        return 3, td_creeps.index(n)\n    return [\"arrow\", \"cannon\", \"frost\"].index(n.split(\"-\")[0]), int(n[-1]) - 1\n\ndef td_film(w, h, frames):\n    td_reset()\n    td_render_settings(w, h)\n    scene.frame_start = 1\n    scene.frame_end = frames\n    half = frames // 2\n    for n in td_names:\n        o = bpy.data.objects[n]\n        col, row = td_place(n)\n        o.location = ((col - 1.5) * 1.9, (row - 1) * 2.5, 0.0)\n        td_turn(o, 1, frames)\n        t = td_text(\"label \" + n, n, 0.22, (0.9, 0.9, 0.85))\n        t.data.align_x = \"CENTER\"\n        t.location = (o.location[0], o.location[1] - 0.72, 0.01)\n        td_play(n, \"idle\", td_loop(\"idle\", 1, half))\n        if n in td_creeps:\n            td_play(n, \"walk\", td_loop(\"walk\", half + 1, frames))\n        else:\n            td_play(n, \"fire\", range(half + 1, frames - td_frames(\"fire\") + 1, scene.render.fps))\n    td_camera((0.0, 0.3, 0.5), 10.0, 20.0, 40, 0)\n\n"
Used in: script

ˡs̲tills : a -> Char

function · line 286

td:s_tills size: Python rendering each piece alone as out/NAME.png, size pixels square on a transparent ground, from the front a little to the right and above (all at one scale, so their sizes compare)

ˡs̲tills ← { size → "td_stills(" c̲at (f̲ormat size) c̲at ")\n" }
Used in: script

ˡs̲heets : Any c => (a, b) -> c -> Char

function · line 299

(turn, map) td:s_heets 0: Python rendering each piece's fallback sheets for a game without 3D, joined in Blender (transparent PNGs): out/NAME-turn.png, 16 frames turn pixels square in a 4 by 4 sheet (row by row), the piece turned 22.5 degrees counterclockwise (seen from above) each frame from its front, the camera 20 degrees up, each piece framed to its size; out/NAME-map.png, 8 frames map pixels square in a row, the piece facing east, then each 45 degrees turned clockwise on screen (east, southeast, south, ... northeast), an orthographic camera 30 degrees up -- the game's board: tiles 64 pixels wide and 32 high in a 96-pixel frame -- the tile's middle at (48, 82) of the frame

ˡs̲heets ← { (turn, map) z → "td_sheets(" c̲at (f̲ormat turn) c̲at ", " c̲at (f̲ormat map) c̲at ")\n" }
Used in: script

ˡc̲loseups : Any d => (a, b, c) -> d -> Char

function · line 306

(width, height, frames) td:c_loseups 0: Python showing the pieces one after another for a video of that size, frames for each (at 30 a second): each alone and close, turning once round, idle for the first half, then fire (towers) or walk and hit (creeps), a caption naming the piece and the clip. bp:v_ideo renders it.

ˡc̲loseups ← { (w, h, seg) z → "td_closeups(" c̲at (f̲ormat w) c̲at ", " c̲at (f̲ormat h) c̲at ", " c̲at (f̲ormat seg) c̲at ")\n" }
Used in: script

ˡf̲ilm : Any d => (a, b, c) -> d -> Char

function · line 313

(width, height, frames) td:f_ilm 0: Python lining the pieces up on the ground for a video of that size and length (at 30 frames a second, the clips' rate): each turns once round, idle in the first half, then the towers fire each second and the creeps walk; a label in front of each. bp:v_ideo renders it.

ˡf̲ilm ← { (w, h, frames) z → "td_film(" c̲at (f̲ormat w) c̲at ", " c̲at (f̲ormat h) c̲at ", " c̲at (f̲ormat frames) c̲at ")\n" }
Used in: script

Publishing them

ʰc̲reep : (Num a, Truthy a) => Char -> a

function (private) · line 318
ʰc̲reep ← { name → (name m̲atch "runner") + (name m̲atch "brute") + (name m̲atch "shield") × 1 }

ʰk̲ind : Truthy a => a -> Char

function (private) · line 321
ʰk̲ind ← { c → c ? "creep"
  "tower"
}
Used in: ʰe̲ntry

ʰc̲lipsOf : Truthy a => a -> Char

function (private) · line 324
ʰc̲lipsOf ← { c → c ? "{ idle = 2.0, walk = 1.0, hit = 0.3 }"
  "{ idle = 2.0, fire = 0.4 }"
}
Used in: ʰe̲ntry

ʰe̲ntry : Any a => (Char, Char) -> a -> Char

function (private) · line 330
ʰe̲ntry ← { (dir, name) z →
  c ← ʰc̲reep name
  (("\n[pieces." c̲at name c̲at "]\nkind = \"" c̲at (ʰk̲ind c) c̲at "\"\nglb = \"" c̲at name c̲at ".glb\"\nglb-sha256 = \"" c̲at (ᵈᵍs̲ha256File dir c̲at "/" c̲at name c̲at ".glb") c̲at "\"\n") c̲at
    ("preview = \"" c̲at name c̲at ".png\"\npreview-sha256 = \"" c̲at (ᵈᵍs̲ha256File dir c̲at "/" c̲at name c̲at ".png") c̲at "\"\n") c̲at
    ("turn = \"" c̲at name c̲at "-turn.png\"\nturn-sha256 = \"" c̲at (ᵈᵍs̲ha256File dir c̲at "/" c̲at name c̲at "-turn.png") c̲at "\"\n") c̲at
    ("map = \"" c̲at name c̲at "-map.png\"\nmap-sha256 = \"" c̲at (ᵈᵍs̲ha256File dir c̲at "/" c̲at name c̲at "-map.png") c̲at "\"\n") c̲at
    ("mesh = \"" c̲at name c̲at "-mesh.toml\"\nmesh-sha256 = \"" c̲at (ᵈᵍs̲ha256File dir c̲at "/" c̲at name c̲at "-mesh.toml") c̲at "\"\n") c̲at
    "clips = " c̲at (ʰc̲lipsOf c) c̲at "\n")
}
Used in: ˡm̲anifest

ˡm̲anifest : Any a => (Char, Char) -> a -> Char

function · line 348

(dir, blender) td:m_anifest 0: manifest.toml for the pieces in dir (their .glb and .png files, hashed by the digest extension): what made them (the program, the commit -- "unpublished" until the files are published -- and Blender, its version line), the license, the conventions (units, up, front, the clips' rate, the sheets, the low-poly mesh's format), then each piece: its kind, files (.glb, preview, sheets, mesh), SHA-256s and clips with their lengths in seconds

ˡm̲anifest ← { (dir, blender) z →
  t ← ("# Tower defense pieces for X_eTaL-games, made by X_eTaL driving Blender.\ntitle = \"Tower defense pieces\"\nprogram = \"extensions/blender/demos/game-assets.xtl\"\npieces-library = \"extensions/blender/demos/Td.xtl\"\n" c̲at
    ("repository = \"https://github.com/softwarewrighter/X_eTaL-extensions\"\ncommit = \"unpublished\"\nlicense = \"MIT\"\nblender = \"" c̲at blender c̲at "\"\n") c̲at
    "format = \"glTF 2.0, binary (.glb)\"\nunits = \"meters: one tile is 1 by 1; the origin at the middle of the base, on the ground\"\nup = \"+Y in glTF (+Z in Blender)\"\nfront = \"+Z in glTF, glTF's own front (-Y in Blender)\"\nclip-rate = 30\n" c̲at
    "preview = \"PIECE.png: 320 by 320, RGBA, transparent, the piece at rest from the front a little right and above, every preview at one scale\"\n" c̲at
    "turn-sheet = { file = \"PIECE-turn.png\", frame = 256, frames = 16, columns = 4, order = \"row by row\", turn = \"22.5 degrees counterclockwise seen from above each frame, frame 0 the front\", camera = \"20 degrees above the horizon\", scale = \"each piece framed to its size\" }\n" c̲at
    "map-sheet = { file = \"PIECE-map.png\", frame = 96, frames = 8, columns = 8, facing = [\"east\", \"southeast\", \"south\", \"southwest\", \"west\", \"northwest\", \"north\", \"northeast\"], camera = \"orthographic, 30 degrees above the horizon (the board's 2:1 tiles; the ask said 35)\", tile = \"64 by 32 pixels\", pixels-per-meter = 45.25, anchor = [48, 82] }\n" c̲at
    "mesh-format = { file = \"PIECE-mesh.toml\", pose = \"at rest\", vertices = \"x y z per string, meters, Z up, front -Y, the origin at the middle of the base\", faces = \"three vertex numbers per string, from 1\", colors = \"#rrggbb per face, sRGB\", most-triangles = " c̲at (f̲ormat ˡmeshMost) c̲at " }\n")
  e̲nt ← { name → (dir, name) ʰe̲ntry 0 }
  t c̲at (e̲nt "arrow-1") c̲at (e̲nt "arrow-2") c̲at (e̲nt "arrow-3") c̲at (e̲nt "cannon-1") c̲at (e̲nt "cannon-2") c̲at (e̲nt "cannon-3") c̲at (e̲nt "frost-1") c̲at (e̲nt "frost-2") c̲at (e̲nt "frost-3") c̲at (e̲nt "runner") c̲at (e̲nt "brute") c̲at e̲nt "shield"
}
Used in: m

ʰc̲ard : Char -> Char

function (private) · line 362
ʰc̲ard ← { name →
  c ← ʰc̲reep name
  t ← "<div class='card'><model-viewer src='" c̲at name c̲at ".glb' poster='" c̲at name c̲at ".png' alt='the " c̲at name c̲at " piece' camera-controls autoplay animation-name='idle' camera-orbit='25deg 70deg auto' shadow-intensity='1' interaction-prompt='none'></model-viewer>"
  t c̲at "<h2>" c̲at name c̲at "</h2><p>" c̲at (ʰb̲uttons c) c̲at " <a href='" c̲at name c̲at ".glb'>.glb</a> <a href='" c̲at name c̲at ".png'>.png</a> <a href='" c̲at name c̲at "-turn.png'>turn</a> <a href='" c̲at name c̲at "-map.png'>map</a> <a href='" c̲at name c̲at "-mesh.toml'>mesh</a></p></div>\n"
}
Used in: ˡpage

ʰb̲uttons : (Num a, Truthy a) => a -> Char

function (private) · line 367
ʰb̲uttons ← { c → c ? "<button data-clip='idle'>idle</button><button data-clip='walk'>walk</button><button data-clip='hit'>hit</button>"
  "<button data-clip='idle'>idle</button><button data-clip='fire'>fire</button>"
}
Used in: ʰc̲ard

ʰp̲ageHead : Any a => a -> Char

function (private) · line 371
ʰp̲ageHead ← { z →
  ("<!doctype html>\n<html lang='en'>\n<head>\n<meta charset='utf-8'>\n<meta name='viewport' content='width=device-width, initial-scale=1'>\n<title>Tower defense pieces -- X_eTaL Extensions</title>\n<link rel='icon' href='../../favicon.ico'>\n" c̲at
    "<script type='module' src='https://cdn.jsdelivr.net/npm/@google/model-viewer@4/dist/model-viewer.min.js'></script>\n" c̲at
    "<style>\nbody { margin: 0 auto; max-width: 1100px; padding: 16px; background: #14161a; color: #e4e4e4; font: 16px/1.5 system-ui, sans-serif; }\na { color: #8cc8ff; }\nheader a { display: flex; align-items: center; gap: 12px; text-decoration: none; }\nheader span { color: #ff3b30; font-size: 28px; font-weight: 700; }\n" c̲at
    ".grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 16px; }\n.card { background: #1d2026; border-radius: 8px; padding: 8px; }\nmodel-viewer { width: 100%; height: 240px; background: #3a7d44; border-radius: 6px; }\n" c̲at
    "h2 { margin: 6px 0 0; font-size: 18px; }\n.card p { margin: 4px 0; }\nbutton { margin: 0 4px 4px 0; background: #2b3038; color: #e4e4e4; border: 1px solid #444b55; border-radius: 4px; padding: 2px 10px; cursor: pointer; }\n</style>\n</head>\n<body>\n" c̲at
    "<header><a href='../../'><img src='../../xetal-logo-red.png' alt='X_eTaL' height='48'><span>X_eTaL Extensions</span></a></header>\n<h1>Tower defense pieces</h1>\n" c̲at
    "<p>The twelve pieces <a href='https://softwarewrighter.github.io/X_eTaL-games/tower-defense/'>X_eTaL-games' tower defense</a> asked for, each made by an X_eTaL program driving Blender (<a href='https://github.com/softwarewrighter/X_eTaL-extensions/blob/main/extensions/blender/demos/game-assets.xtl'>game-assets.xtl</a>, the pieces in <a href='https://github.com/softwarewrighter/X_eTaL-extensions/blob/main/extensions/blender/demos/Td.xtl'>Td.xtl</a>). " c̲at
    "Drag a piece to turn it; the buttons play its clips. Each is a .glb (glTF 2.0) with its clips, a preview .png and two sheets for a game without 3D (turn: 16 views; map: 8 facings on the isometric board) and a low-poly mesh in TOML for a renderer written in X_eTaL; <a href='manifest.toml'>manifest.toml</a> lists them with their SHA-256s, the license (MIT) and the commit that made them.</p>\n<main class='grid'>\n")
}
Used in: ˡpage

ʰp̲ageEnd : Any a => a -> Char

function (private) · line 382
ʰp̲ageEnd ← { z → "</main>\n<script>\ndocument.querySelectorAll('button[data-clip]').forEach(function (b) {\n  b.onclick = function () {\n    var mv = b.closest('.card').querySelector('model-viewer');\n    var loop = b.dataset.clip === 'idle' || b.dataset.clip === 'walk';\n    mv.animationName = b.dataset.clip;\n    mv.currentTime = 0;\n    mv.play({repetitions: loop ? Infinity : 1});\n  };\n});\ndocument.querySelectorAll('model-viewer').forEach(function (mv) {\n  mv.addEventListener('finished', function () { mv.animationName = 'idle'; mv.play(); });\n});\n</script>\n</body>\n</html>\n" }
Used in: ˡpage

ˡpage : Char

value · line 388

td:page: the pieces' page (index.html beside the files): each piece in a 3D viewer (model-viewer, from a CDN) to turn with the mouse, its clips on buttons, its files; links to the manifest, the program and the game

ˡpage ← (ʰp̲ageHead 0) c̲at (ʰc̲ard "arrow-1") c̲at (ʰc̲ard "arrow-2") c̲at (ʰc̲ard "arrow-3") c̲at (ʰc̲ard "cannon-1") c̲at (ʰc̲ard "cannon-2") c̲at (ʰc̲ard "cannon-3") c̲at (ʰc̲ard "frost-1") c̲at (ʰc̲ard "frost-2") c̲at (ʰc̲ard "frost-3") c̲at (ʰc̲ard "runner") c̲at (ʰc̲ard "brute") c̲at (ʰc̲ard "shield") c̲at ʰp̲ageEnd 0
Used in: p