#!/usr/bin/env python3 """Render a map.bin to a PNG using the real tile atlases + wax sprites. Offline view of exactly what the engine will draw, so terrain can be checked without a display. Usage: render_map.py [out.png] """ import os, struct, sys from PIL import Image ROOT = os.path.join(os.path.dirname(__file__), '..') MOD = os.path.join(ROOT, 'mods', 'vinylgod') TPL = {255: 'asphalt', 1: 'concrete', 2: 'dirt', 3: 'grooves', 4: 'rubble'} TILE = 32 name = sys.argv[1] if len(sys.argv) > 1 else 'arena' out = sys.argv[2] if len(sys.argv) > 2 else os.path.join(ROOT, 'assets_src', f'map_{name}.png') atlas = {} for tid, n in TPL.items(): im = Image.open(os.path.join(MOD, 'tilesets', 'vinylgod', f'{n}.png')).convert('RGBA') atlas[tid] = [im.crop((i * TILE, 0, (i + 1) * TILE, TILE)) for i in range(im.width // TILE)] wax_sheet = Image.open(os.path.join(MOD, 'sequences', 'assets', 'wax.png')).convert('RGBA') wax = [wax_sheet.crop((i * 32, 0, (i + 1) * 32, 32)) for i in range(wax_sheet.width // 32)] d = open(os.path.join(MOD, 'maps', name, 'map.bin'), 'rb').read() fmt, w, h = d[0], *struct.unpack_from(' {out} ({img.width}x{img.height})')