-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.py
More file actions
65 lines (57 loc) · 1.54 KB
/
Copy pathtest.py
File metadata and controls
65 lines (57 loc) · 1.54 KB
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
import json
level = [
"#######################",
"#.....................#",
"#.#.#.#.#.#.#.#.#.#.#.#",
"#.....................#",
"#.#.#.#.#.#.#.#.#.#.#.#",
"#.....................#",
"#.#.#.#.#.#.#.#.#.#.#.#",
"#.....................#",
"#.#.#.#.#.#.#.#.#.#.#.#",
"#.....................#",
"#.#.#.#.#.#.#.#.#.#.#.#",
"#.....................#",
"#.#.#.#.#.#.#.#.#.#.#.#",
"#.....................#",
"#######################",
]
f = open("res/levels/test.lev", "w")
out = {
"settings": {
"width": len(level[0]) * 64,
"height": len(level) * 64
},
"ui": {},
"objects": [
{
"class_name": "NetworkManager",
"properties": {
"position": [-100, -100]
}
}
]
}
for i, line in enumerate(level):
for j, block in enumerate(line):
if block == "#":
out["objects"].append({
"class_name": "Block",
"properties": {
"position": [64 * j, 64 * i],
"texture": "res/textures/Brick.png",
"collider": 0
}
})
if block == ".":
out["objects"].append({
"class_name": "Blank",
"properties": {
"position": [64 * j, 64 * i],
"texture": "res/textures/Grass.png",
"collider": 2
}
})
out_json = json.dumps(out, indent=4)
f.write(out_json)
f.close()