Updated map converter to align actors to the tile grid
authorLukas Krickl <lukas@krickl.dev>
Mon, 25 Nov 2024 10:50:07 +0000 (11:50 +0100)
committerLukas Krickl <lukas@krickl.dev>
Mon, 25 Nov 2024 10:50:07 +0000 (11:50 +0100)
maps/base_room.s
tools/tms2map.py

index efccf5e9e3416af1784d2e4136eee9b4cf03d405..68abba5c4fb1cefb4a1cf957f172d9962452b115 100644 (file)
@@ -5,8 +5,8 @@ dwb base_room_flags
 dwb base_room_actors
 base_room_actors:
 .db  8
-.db  1 , 67 , 54 , 0
-.db  1 , 55 , 40 , 0
+.db  1 , 64 , 72 , 0
+.db  1 , 48 , 56 , 0
 base_room_bg:
 .db 0x60, 0x62, 0x62, 0x64, 0x40, 0x40, 0x66, 0x62, 0x62, 0x68, 0x4c, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x6a, 0x46, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0xe0, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x48, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0xe2, 0x4c, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x6a, 0x6c, 0x4a, 0x4a, 0x42, 0x40, 0x40, 0x44, 0x4a, 0x4a, 0x6e
 base_room_flags:
index c7248d4fd7e482ba0073c3dc7d85a7b049ed63e0..50e917720a6a344e797dc046f1753b7f69711783 100755 (executable)
@@ -4,6 +4,10 @@ import sys
 import os
 import xml.etree.ElementTree as ET
 
+TILE_SIZE = 16
+ACTOR_OFFSET_X = 8
+ACTOR_OFFSET_Y = 16
+
 if len(sys.argv) < 3:
     print("Usage: tmx2map.py <source> <map name>")
     sys.exit(-1)
@@ -30,8 +34,11 @@ def print_data(data, name, layer):
             end = '\n'
         print(hex(val), end=end)
 
+def actor_round(n, base=TILE_SIZE):
+    return base * round(n/base)
+
 def print_actor(atype, y, x, flags):
-    print(".db ", int(atype), ",", int(float(y)), ",", int(float(x)), ",", int(flags))
+    print(".db ", int(atype), ",", int(actor_round(float(y))) + ACTOR_OFFSET_Y, ",", int(actor_round(float(x)))  + ACTOR_OFFSET_X, ",", int(flags))
 
 def print_struct(name):
     print(" ; struct for ", name)
@@ -62,7 +69,7 @@ def convert(src, name):
                             atype = prop.attrib['value']
                         elif prop.attrib['name'] == 'flags':
                             flags = prop.attrib['value']
-                print_actor(atype, data.attrib['x'], data.attrib['y'], flags)
+                print_actor(atype, data.attrib['y'], data.attrib['x'], flags)