You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
22 lines
659 B
22 lines
659 B
1 month ago
|
"""
|
||
|
Converts json level data files into binary level data
|
||
|
"""
|
||
|
import json
|
||
|
from os import listdir
|
||
|
from os.path import isfile, join
|
||
|
|
||
|
LVL_DIR = "lvl/"
|
||
|
BIN_DIR = "lvl_bin/"
|
||
|
|
||
|
if __name__ == "__main__":
|
||
|
files = [f for f in listdir(LVL_DIR) if isfile(join(LVL_DIR, f))]
|
||
|
decoder = json.JSONDecoder()
|
||
|
for v in files:
|
||
|
file = open(join(LVL_DIR, v), "r", encoding="utf-8")
|
||
|
content = decoder.decode(file.read())
|
||
|
newfile = open(join(BIN_DIR, v.replace(".json", ".dat")), "wb")
|
||
|
bin_content = b''
|
||
|
for line in content:
|
||
|
bin_content += bytes(line+[255])
|
||
|
newfile.write(bin_content)
|