Update ldtk repacker

Changelog:
- Remove level rendering. This is done in-game
- Report maximum number of tiles present in a level
main
En Yi 2025-08-18 21:45:45 +08:00
parent c8e297265f
commit c2f673f5b8
2 changed files with 4 additions and 1 deletions

View File

@ -79,6 +79,7 @@ else:
fileparts[-1] = "lvldata"
converted_filename = '.'.join(fileparts)
max_n_tiles = 0
# Each level should be packed as: [width, 2 bytes][height, 2 bytes][tile_type,entity,water,padding 1,1,1,1 bytes][tile_type,entity,water,padding 1,1,1,1 bytes]...
with open(converted_filename, 'wb+') as out_file:
out_file.write(struct.pack("<I", n_levels))
@ -113,6 +114,7 @@ with open(converted_filename, 'wb+') as out_file:
width = level_layout["__cWid"]
height = level_layout["__cHei"]
print(f"Dim.: {width}x{height}. N Tiles: {width * height}")
max_n_tiles = max(max_n_tiles, width*height)
# Create a W x H array of tile information
n_tiles = width * height
tiles_info = [[0,0,0] for _ in range(n_tiles)]
@ -154,3 +156,4 @@ with open(converted_filename, 'wb+') as out_file:
# print(tiles_info[y*width + x], end=" ")
# print()
print("Largest number of tiles:", max_n_tiles)

View File

@ -1,3 +1,3 @@
#!/bin/bash
source venv/bin/activate
python ldtk_repacker.py $1.ldtk && zstd $1.lvldata && python level_render.py $1.ldtk
python ldtk_repacker.py $1.ldtk && zstd $1.lvldata