-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathdata.go
78 lines (68 loc) · 2.17 KB
/
data.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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
package ebitmx
import "encoding/xml"
// Tileset represents a set of tiles in a TMX, or a TSX file
type Tileset struct {
XMLName xml.Name `xml:"tileset"`
Version string `xml:"version,attr"`
Name string `xml:"name,attr"`
TileWidth int `xml:"tilewidth,attr"`
TileHeight int `xml:"tileheight,attr"`
TileCount int `xml:"tilecount,attr"`
Columns int `xml:"columns,attr"`
Image Image `xml:"image"`
Tiles []Tile `xml:"tile"`
}
type Image struct {
XMLName xml.Name `xml:"image"`
Format string `xml:"format"`
Source string `xml:"source"`
Width int `xml:"width,attr"`
Height int `xml:"height,attr"`
}
type Tile struct {
XMLName xml.Name `xml:"tile"`
Id int `xml:"id,attr"`
Type string `xml:"type,attr"`
Properties Properties `xml:"properties"`
}
type Properties struct {
XMLName xml.Name `xml:"properties"`
Properties []Property `xml:"property"`
}
type Property struct {
XMLName xml.Name `xml:"property"`
Name string `xml:"name,attr"`
Type string `xml:"type,attr"`
Value string `xml:"value,attr"`
}
// Map is the representation of a map in a TMX file
type Map struct {
XMLName xml.Name `xml:"map"`
Version string `xml:"version,attr"`
TiledVersion string `xml:"tiledversion,attr"`
Orientation string `xml:"orientation,attr"`
RenderOrder string `xml:"renderorder,attr"`
Width int `xml:"width,attr"`
Height int `xml:"height,attr"`
TileWidth int `xml:"tilewidth,attr"`
TilHeight int `xml:"tileheight,attr"`
Infinite bool `xml:"infinite,attr"`
// TODO nextlayerid and nextobjectid ?
//Tileset []Tileset `xml:"tileset"`
Layers []Layer `xml:"layer"`
}
// Layer represents a layer in the TMX map file
type Layer struct {
XMLName xml.Name `xml:"layer"`
ID string `xml:"id,attr"`
Name string `xml:"name,attr"`
Data Data `xml:"data"`
Width int `xml:"width,attr"`
Height int `xml:"height,attr"`
}
// Data represents the data inside a Layer
type Data struct {
XMLName xml.Name `xml:"data"`
Encoding string `xml:"encoding,attr"`
Raw []byte `xml:",innerxml"`
}