-
-
Notifications
You must be signed in to change notification settings - Fork 43
/
example_test.go
59 lines (48 loc) · 1.29 KB
/
example_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
// Examples
package tiled_test
import (
"fmt"
"os"
"github.com/lafriks/go-tiled"
)
func ExampleTileset_GetTilesetTile() {
var tiledMap *tiled.Map
var err error
tiledMap, err = tiled.LoadFile("assets/test_wangsets_w_properties_map.tmx")
if err != nil {
fmt.Printf("error parsing tiledMap: %s", err.Error())
os.Exit(2)
}
// get the tile so that we can read its data
tile, err := tiledMap.Layers[0].Tiles[0].Tileset.GetTilesetTile(15)
if err != nil {
panic(err)
}
fmt.Print(tile.ID)
// Output:
// 15
}
func ExampleWangSet_GetWangColors() {
var tiledMap *tiled.Map
var err error
tiledMap, err = tiled.LoadFile("assets/test_wangsets_map.tmx")
if err != nil {
fmt.Printf("error parsing tiledMap: %s", err.Error())
os.Exit(2)
}
fmt.Println(tiledMap.Tilesets[0].WangSets[0].Name)
wangColors, err := tiledMap.Tilesets[0].WangSets[0].GetWangColors(16)
if err != nil {
panic(err)
}
fmt.Printf(" TopRight: %s\n", wangColors[tiled.TopRight].Name)
fmt.Printf(" BottomRight: %s\n", wangColors[tiled.BottomRight].Name)
fmt.Printf(" BottomLeft: %s\n", wangColors[tiled.BottomLeft].Name)
fmt.Printf(" TopLeft: %s\n", wangColors[tiled.TopLeft].Name)
// Output:
// Summer
// TopRight: Rock
// BottomRight: Water
// BottomLeft: Water
// TopLeft: Rock
}