|
@ -24,7 +24,7 @@ Point = Tuple[int, int] |
|
|
|
|
|
|
|
|
def generate_coll_map( |
|
|
def generate_coll_map( |
|
|
in_path: pathlib.Path, width: int, height: int, compress: bool = False |
|
|
in_path: pathlib.Path, width: int, height: int, compress: bool = False |
|
|
) -> Tuple[str, Point, Point]: |
|
|
|
|
|
|
|
|
) -> Tuple[bytes, Point, Point]: |
|
|
png = Image.open(in_path).convert("RGB") |
|
|
png = Image.open(in_path).convert("RGB") |
|
|
if png.width % 8 != 0 or png.height % 8 != 0: |
|
|
if png.width % 8 != 0 or png.height % 8 != 0: |
|
|
abort(f"file '{in_path}' has invalid dimensions (should be multiple of 8)") |
|
|
abort(f"file '{in_path}' has invalid dimensions (should be multiple of 8)") |
|
@ -69,7 +69,7 @@ def generate_coll_map( |
|
|
if spawn is None: |
|
|
if spawn is None: |
|
|
abort(f"no spawn point located") |
|
|
abort(f"no spawn point located") |
|
|
|
|
|
|
|
|
return format_bytes(out_bytes, width=width), spawn, camera |
|
|
|
|
|
|
|
|
return bytes(out_bytes), spawn, camera |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def format_bytes(data: bytes, width: int = 16) -> str: |
|
|
def format_bytes(data: bytes, width: int = 16) -> str: |
|
@ -115,10 +115,14 @@ def generate_map(pngfile: str, compress: bool = False) -> None: |
|
|
) |
|
|
) |
|
|
|
|
|
|
|
|
collpath = pngpath.parent / pngpath.name.replace(".png", "_coll.png") |
|
|
collpath = pngpath.parent / pngpath.name.replace(".png", "_coll.png") |
|
|
|
|
|
collpath_out = pngpath.parent / f"{section}.collision" |
|
|
coll_map, spawn, camera = generate_coll_map( |
|
|
coll_map, spawn, camera = generate_coll_map( |
|
|
collpath, width, height, compress=compress |
|
|
collpath, width, height, compress=compress |
|
|
) |
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
with open(collpath_out, "wb") as outf: |
|
|
|
|
|
outf.write(coll_map) |
|
|
|
|
|
|
|
|
tiles_size = os.path.getsize(tilepath) |
|
|
tiles_size = os.path.getsize(tilepath) |
|
|
|
|
|
|
|
|
with open(incpath, "w") as outf: |
|
|
with open(incpath, "w") as outf: |
|
@ -140,11 +144,7 @@ extern map_t map_{section}; |
|
|
|
|
|
|
|
|
MAP_ASSET({section}_tiles, "{section}.tiles"); |
|
|
MAP_ASSET({section}_tiles, "{section}.tiles"); |
|
|
MAP_ASSET({section}_map, "{section}.tilemap"); |
|
|
MAP_ASSET({section}_map, "{section}.tilemap"); |
|
|
//MAP_ASSET({section}_collision, "{section}.collision"); |
|
|
|
|
|
|
|
|
|
|
|
const uint8_t {section}_collision[] = {{ |
|
|
|
|
|
{coll_map} |
|
|
|
|
|
}}; |
|
|
|
|
|
|
|
|
MAP_ASSET({section}_collision, "{section}.collision"); |
|
|
|
|
|
|
|
|
const map_t map_{section} = {{ |
|
|
const map_t map_{section} = {{ |
|
|
(uint16_t)&{section}_tiles[0], |
|
|
(uint16_t)&{section}_tiles[0], |
|
|