parse-tmx 2.1.0 → 2.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (5) hide show
  1. package/LICENSE +201 -201
  2. package/README.md +125 -125
  3. package/dist/index.d.ts +147 -153
  4. package/dist/index.js +58261 -43236
  5. package/package.json +13 -13
package/README.md CHANGED
@@ -1,125 +1,125 @@
1
- # parse-tmx
2
-
3
- <p>
4
- <a href="https://www.npmjs.com/package/parse-tmx">
5
- <img src="https://img.shields.io/npm/v/parse-tmx.svg?style=flat&colorA=18181B&colorB=28CF8D" alt="Version">
6
- </a>
7
- <a href="https://www.npmjs.com/package/parse-tmx">
8
- <img src="https://img.shields.io/npm/dm/parse-tmx.svg?style=flat&colorA=18181B&colorB=28CF8D" alt="Downloads">
9
- </a>
10
- <a href="https://github.com/Esposter/Esposter/blob/main/LICENSE">
11
- <img src="https://img.shields.io/github/license/Esposter/Esposter.svg?style=flat&colorA=18181B&colorB=28CF8D" alt="License">
12
- </a>
13
- </p>
14
-
15
- Inspired by [tmx-map-parser](https://github.com/praghus/tmx-map-parser).
16
- A parser for [Tiled Map Editor](http://www.mapeditor.org/) \*.tmx files.
17
-
18
- ### Table of Contents
19
-
20
- - 🚀 [Getting Started](#getting-started)
21
- - 📖 [Documentation](#documentation)
22
- - ⚖️ [License](#license)
23
-
24
- ---
25
-
26
- ## <a name="getting-started">🚀 Getting Started</a>
27
-
28
- ```bash
29
- pnpm i parse-tmx
30
- ```
31
-
32
- ## <a name="documentation">📖 Documentation</a>
33
-
34
- We highly recommend you take a look at the [documentation](https://esposter.com/docs/modules/parse_tmx.html) to level up.
35
-
36
- ### Usage
37
-
38
- The basic implementation:
39
-
40
- ```ts
41
- import { parseTmx } from "parse-tmx";
42
- // The *.tmx file can be loaded as a string or URL encoded data
43
- import map from "map.tmx";
44
-
45
- // Translates the tile flips in the layer data (default: false)
46
- const translateFlips = true;
47
-
48
- const loadMap = async () => {
49
- const data = await parseTmx(map, translateFlips);
50
- ...
51
- };
52
- ```
53
-
54
- ### Example data
55
-
56
- [TMX Map Format documentation](https://doc.mapeditor.org/en/stable/reference/tmx-map-format/)
57
-
58
- ```js
59
- {
60
- tiledversion: "1.8.0",
61
- tilewidth: 16,
62
- tileheight: 16,
63
- version: 1.8,
64
- width: 512,
65
- height: 128,
66
- infinite: 0,
67
- nextlayerid: 5,
68
- nextobjectid: 165,
69
- orientation: "orthogonal",
70
- renderorder: "right-down",
71
- properties: {
72
- property1: 'value',
73
- property2: 0.5
74
- },
75
- layers: [{
76
- id: 1,
77
- name: "layer name",
78
- type: "layer",
79
- visible: 1,
80
- data: [0, 1, 1, 10, 10, 10, 1, 1, 0, 0, 0, 0, …],
81
- // When the translateFlips parameter is enabled
82
- flips: [
83
- {H: false, V: false, D: false},
84
- {H: true, V: false, D: true},
85
- {H: false, V: false, D: false},
86
- {…}
87
- ],
88
- width: 512,
89
- height: 128,
90
- opacity: 0.77,
91
- properties: {
92
- property1: 'value',
93
- property2: false
94
- }
95
- }, {
96
- id: 2,
97
- name: "objects",
98
- type: "objectgroup",
99
- visible: 1,
100
- objects: [{…}, {…}, {…}],
101
- properties: {
102
- property1: 'value',
103
- property2: false
104
- }
105
- }, {
106
- …
107
- }],
108
- tilesets: [{
109
- columns: 32,
110
- firstgid: 1,
111
- image: {source: "tiles.png", width: 512, height: 512},
112
- name: "tiles",
113
- tilecount: 1024,
114
- tilewidth: 16,
115
- tileheight: 16,
116
- tiles: [{…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}]
117
- }, {
118
- …
119
- }]
120
- }
121
- ```
122
-
123
- ## <a name="license">⚖️ License</a>
124
-
125
- [Apache-2.0 licensed](https://github.com/Esposter/Esposter/blob/main/LICENSE)
1
+ # parse-tmx
2
+
3
+ [![Apache-2.0 licensed][badge-license]][url-license]
4
+ [![NPM version][badge-npm-version]][url-npm]
5
+ [![NPM downloads][badge-npm-downloads]][url-npm]
6
+ [![NPM Unpacked Size (with version)][badge-npm-unpacked-size]][url-npm]
7
+
8
+ Inspired by [tmx-map-parser](https://github.com/praghus/tmx-map-parser).
9
+ A parser for [Tiled Map Editor](http://www.mapeditor.org/) \*.tmx files.
10
+
11
+ ### Table of Contents
12
+
13
+ - 🚀 [Getting Started](#getting-started)
14
+ - 📖 [Documentation](#documentation)
15
+ - ⚖️ [License](#license)
16
+
17
+ ---
18
+
19
+ ## <a name="getting-started">🚀 Getting Started</a>
20
+
21
+ ```bash
22
+ pnpm i parse-tmx
23
+ ```
24
+
25
+ ## <a name="documentation">📖 Documentation</a>
26
+
27
+ We highly recommend you take a look at the [documentation](https://esposter.com/docs/modules/parse_tmx.html) to level up.
28
+
29
+ ### Usage
30
+
31
+ The basic implementation:
32
+
33
+ ```ts
34
+ import { parseTmx } from "parse-tmx";
35
+ // The *.tmx file can be loaded as a string or URL encoded data
36
+ import map from "map.tmx";
37
+
38
+ // Translates the tile flips in the layer data (default: false)
39
+ const translateFlips = true;
40
+
41
+ const loadMap = async () => {
42
+ const data = await parseTmx(map, translateFlips);
43
+ ...
44
+ };
45
+ ```
46
+
47
+ ### Example data
48
+
49
+ [TMX Map Format documentation](https://doc.mapeditor.org/en/stable/reference/tmx-map-format/)
50
+
51
+ ```js
52
+ {
53
+ tiledversion: "1.8.0",
54
+ tilewidth: 16,
55
+ tileheight: 16,
56
+ version: 1.8,
57
+ width: 512,
58
+ height: 128,
59
+ infinite: 0,
60
+ nextlayerid: 5,
61
+ nextobjectid: 165,
62
+ orientation: "orthogonal",
63
+ renderorder: "right-down",
64
+ properties: {
65
+ property1: 'value',
66
+ property2: 0.5
67
+ },
68
+ layers: [{
69
+ id: 1,
70
+ name: "layer name",
71
+ type: "layer",
72
+ visible: 1,
73
+ data: [0, 1, 1, 10, 10, 10, 1, 1, 0, 0, 0, 0, …],
74
+ // When the translateFlips parameter is enabled
75
+ flips: [
76
+ {H: false, V: false, D: false},
77
+ {H: true, V: false, D: true},
78
+ {H: false, V: false, D: false},
79
+ {…}
80
+ ],
81
+ width: 512,
82
+ height: 128,
83
+ opacity: 0.77,
84
+ properties: {
85
+ property1: 'value',
86
+ property2: false
87
+ }
88
+ }, {
89
+ id: 2,
90
+ name: "objects",
91
+ type: "objectgroup",
92
+ visible: 1,
93
+ objects: [{…}, {…}, {…}],
94
+ properties: {
95
+ property1: 'value',
96
+ property2: false
97
+ }
98
+ }, {
99
+ …
100
+ }],
101
+ tilesets: [{
102
+ columns: 32,
103
+ firstgid: 1,
104
+ image: {source: "tiles.png", width: 512, height: 512},
105
+ name: "tiles",
106
+ tilecount: 1024,
107
+ tilewidth: 16,
108
+ tileheight: 16,
109
+ tiles: [{…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}]
110
+ }, {
111
+ …
112
+ }]
113
+ }
114
+ ```
115
+
116
+ ## <a name="license">⚖️ License</a>
117
+
118
+ This project is licensed under the [Apache-2.0 license](https://github.com/Esposter/Esposter/blob/main/LICENSE).
119
+
120
+ [badge-license]: https://img.shields.io/github/license/Esposter/Esposter.svg?color=blue
121
+ [url-license]: https://github.com/Esposter/Esposter/blob/main/LICENSE
122
+ [badge-npm-version]: https://img.shields.io/npm/v/parse-tmx/latest?color=brightgreen
123
+ [url-npm]: https://www.npmjs.com/package/parse-tmx/v/latest
124
+ [badge-npm-unpacked-size]: https://img.shields.io/npm/unpacked-size/parse-tmx/latest?label=npm
125
+ [badge-npm-downloads]: https://img.shields.io/npm/dm/parse-tmx.svg