Merge tilesets into one
This commit is contained in:
@@ -23,7 +23,7 @@ class ExtractFileWriter:
|
||||
print(f"#endif // {self.name}")
|
||||
|
||||
def include(self, header):
|
||||
print(f"#include {header}")
|
||||
print(f"${self.indention}#include {header}")
|
||||
|
||||
def enum_start(self, name):
|
||||
print(f"{self.indention}typedef enum {name} {{")
|
||||
|
||||
33
scripts/extract_tileset.py
Normal file
33
scripts/extract_tileset.py
Normal file
@@ -0,0 +1,33 @@
|
||||
import json
|
||||
|
||||
from extract_common import *
|
||||
|
||||
writer = ExtractFileWriter("")
|
||||
|
||||
writer.include("<breeze.h>")
|
||||
|
||||
|
||||
def extract_by_property(tiles, key):
|
||||
extracted = []
|
||||
for tile in tiles:
|
||||
if 'properties' not in tile:
|
||||
continue
|
||||
props = tile['properties']
|
||||
props = [True for prop in props if prop['name'] == key]
|
||||
if any(props):
|
||||
extracted.append(tile)
|
||||
return extracted
|
||||
|
||||
|
||||
content = open("../rawAssets/game.tsj").read()
|
||||
tiles = json.loads(content)["tiles"]
|
||||
terrain = extract_by_property(tiles, "terrain")
|
||||
building = extract_by_property(tiles, "building")
|
||||
entity = extract_by_property(tiles, "entity")
|
||||
print(terrain)
|
||||
|
||||
|
||||
writer.output(f"// This file was generated by: {__file__}\n\n")
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user