aboutsummaryrefslogtreecommitdiff
path: root/scripts/tilemap2tiled
diff options
context:
space:
mode:
authorUnavailableDev <69792062+UnavailableDev@users.noreply.github.com>2023-04-06 12:32:23 +0200
committerGitHub <noreply@github.com>2023-04-06 12:32:23 +0200
commitd1c00c98ca0f2ca498284e60fa057a610cc5c461 (patch)
treea2efebcb9917d7f4f3666a722338f50b9590e843 /scripts/tilemap2tiled
parent1771aaa12736b4dbc24419270cf595de6d345969 (diff)
parent93e9426d5642dfab7a13d5a34873b296de1d9642 (diff)
Merge pull request #58 from UnavailableDev/dev
Dynamic tilemap
Diffstat (limited to 'scripts/tilemap2tiled')
-rwxr-xr-xscripts/tilemap2tiled42
1 files changed, 42 insertions, 0 deletions
diff --git a/scripts/tilemap2tiled b/scripts/tilemap2tiled
new file mode 100755
index 0000000..905f801
--- /dev/null
+++ b/scripts/tilemap2tiled
@@ -0,0 +1,42 @@
+#!/bin/python3
+# read packed tilemap file from argv[1] and output pngs
+
+import sys
+import io
+import struct
+from PIL import Image
+
+color_map = (
+ (0x00, 0x00, 0x00),
+ (0x24, 0x24, 0x24),
+ (0x49, 0x49, 0x49),
+ (0x6d, 0x6d, 0x6d),
+ (0x92, 0x92, 0x92),
+ (0xb6, 0xb6, 0xb6),
+ (0xda, 0xda, 0xda),
+ (0xff, 0xff, 0xff),
+)
+
+img = Image.new('RGB', (16, 16))
+
+buf = ""
+with open(sys.argv[1], "rb") as f:
+ buf = f.read()
+
+i = 0
+sprite_idx = 0
+for x in range(0, len(buf), 2):
+ word = 0x0000
+ word |= buf[x]
+ word |= buf[x+1] << 8
+
+ for p in range(5):
+ img.putpixel((i % 16, i // 16), color_map[(word >> (p * 3)) & 0b111])
+ i += 1
+ if i > 0xff:
+ i = 0
+ img.save(f"tiled/{sys.argv[1].replace('.bin','')}_{str(sprite_idx).zfill(2)}.png", format="PNG")
+ img = Image.new('RGB', (16, 16))
+ sprite_idx += 1
+ break
+