-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmap_to_json.py
58 lines (51 loc) · 1.44 KB
/
map_to_json.py
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
import json
def create_json(width, height, tileset_id, data):
return {
"autoplayBgm": False,
"autoplayBgs": False,
"battleback1Name": "",
"battleback2Name": "",
"bgm": {
"name": "",
"pan": 0,
"pitch": 100,
"volume": 90
},
"bgs": {
"name": "",
"pan": 0,
"pitch": 100,
"volume": 90
},
"disableDashing": False,
"displayName": "",
"encounterList": [],
"encounterStep": 30,
"height": height,
"note": "",
"parallaxLoopX": False,
"parallaxLoopY": False,
"parallaxName": "",
"parallaxShow": False,
"parallaxSx": 0,
"parallaxSy": 0,
"scrollType": 0,
"specifyBattleback": False,
"tilesetId": tileset_id,
"width": width,
"data": data,
"events": []
}
def create_data(map, width, height):
data = []
for r in range(6):
for y in range(height):
for x in range(width):
data.append(map[y][x][r])
return data
def main(map, tileset_id, map_id, output_path):
(width, height) = (len(map[0]), len(map))
data = create_data(map, width, height)
map_json = create_json(width, height, tileset_id, data)
with open(f'{output_path}Map{map_id:03}.json', 'w') as file:
json.dump(map_json, file, separators=(',', ':'))