UNPKG

2.61 kBtext/coffeescriptView Raw
1palette = require './palette.coffee'
2
3map =
4 '': <symbol viewBox="0 0 16 16"/>
5
6 # Environment
7 brick: <symbol viewBox="0 0 16 16"><image xlink:href="brick_#{palette}.png"/></symbol>
8 brick_lit: <symbol viewBox="0 0 16 16"><image xlink:href="brick_lit_#{palette}.png"/></symbol>
9 question: <symbol viewBox="0 0 16 16"><image xlink:href="question_#{palette}.png"/></symbol>
10 question_used: <symbol viewBox="0 0 16 16"><image xlink:href="question_used_#{palette}.png"/></symbol>
11 raised: <symbol viewBox="0 0 16 16"><image xlink:href="raised_#{palette}.png"/></symbol>
12 rock: <symbol viewBox="0 0 16 16"><image xlink:href="rock_#{palette}.png"/></symbol>
13
14 # Players
15 mario_small_left: <symbol viewBox="0 0 16 16" z-index="2"><image y="1" xlink:href="mario_small_left.png"/></symbol>
16 mario_small_right: <symbol viewBox="0 0 16 16" z-index="2"><image y="1" xlink:href="mario_small_right.png"/></symbol>
17 mario_large_left: <symbol viewBox="0 0 16 16" z-index="2"><image y="-15" xlink:href="mario_large_left.png"/></symbol>
18 mario_large_right: <symbol viewBox="0 0 16 16" z-index="2"><image y="-15" xlink:href="mario_large_right.png"/></symbol>
19 luigi_small_left: <symbol viewBox="0 0 16 16" z-index="2"><image y="1" xlink:href="luigi_small_left.png"/></symbol>
20 luigi_small_right: <symbol viewBox="0 0 16 16" z-index="2"><image y="1" xlink:href="luigi_small_right.png"/></symbol>
21 luigi_large_left: <symbol viewBox="0 0 16 16" z-index="2"><image y="-15" xlink:href="luigi_large_left.png"/></symbol>
22 luigi_large_right: <symbol viewBox="0 0 16 16" z-index="2"><image y="-15" xlink:href="luigi_large_right.png"/></symbol>
23
24 # Enemies
25 goomba: <symbol viewBox="0 0 16 16" z-index="1"><image y="1" xlink:href={"goomba_#{palette}".png}/></symbol>
26 spiny_left: <symbol viewBox="0 0 16 16" z-index="1"><image y="1" xlink:href="spiny_left.png"/></symbol>
27 spiny_right: <symbol viewBox="0 0 16 16" z-index="1"><image y="1" xlink:href="spiny_right.png"/></symbol>
28
29build = (key) ->
30 key = key.trim()
31 if ',' in key
32 <symbol viewBox="0 0 16 16">
33 {for subkey in key.split ','
34 tile = build subkey
35 if tile?
36 tile.props?.children
37 else
38 console.warn "Unrecognized subtitle '#{subkey}'"
39 }
40 </symbol>
41 else if match = /^(.*?)([+-]\d+)([+-]\d+)?$/.exec key
42 tile = map[match[1]]
43 offsetX = parseInt match[2]
44 offsetY = parseInt (match[3] ? '0')
45 return unless tile?
46 tile.props.viewBox = tile.props.viewBox.replace /^(\d+) (\d+)/,
47 (m, x, y) -> "#{-offsetX + parseInt x} #{-offsetY + parseInt y}"
48 tile
49 else
50 map[key]