diff options
author | Andrei Karas <akaras@inbox.ru> | 2017-01-31 02:37:42 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2017-01-31 02:37:42 +0300 |
commit | 8abac1bb1168c7adbbb175d663442d7ec112d01c (patch) | |
tree | b752060f114d44de8b9b1ca476a174d26d1a0443 /hercules | |
parent | 1116f3ea796eb5617a570cf03672f6959104a8cb (diff) | |
download | evol-tools-8abac1bb1168c7adbbb175d663442d7ec112d01c.tar.gz evol-tools-8abac1bb1168c7adbbb175d663442d7ec112d01c.tar.bz2 evol-tools-8abac1bb1168c7adbbb175d663442d7ec112d01c.tar.xz evol-tools-8abac1bb1168c7adbbb175d663442d7ec112d01c.zip |
tmx_converter: probably fix spawns conversion.
Diffstat (limited to 'hercules')
-rwxr-xr-x | hercules/tmx_converter.py | 24 |
1 files changed, 14 insertions, 10 deletions
diff --git a/hercules/tmx_converter.py b/hercules/tmx_converter.py index 4d1d833..8638a9c 100755 --- a/hercules/tmx_converter.py +++ b/hercules/tmx_converter.py @@ -207,21 +207,25 @@ class ContentHandler(xml.sax.ContentHandler): elif self.state is State.FINAL: if name == u'object': obj_type = attr[u'type'].lower() - x = int(attr[u'x']) / TILESIZE; - y = int(attr[u'y']) / TILESIZE; - w = int(attr.get(u'width', 0)) / TILESIZE; - h = int(attr.get(u'height', 0)) / TILESIZE; + x = int(int(attr[u'x']) / TILESIZE); + y = int(int(attr[u'y']) / TILESIZE); + w = int(int(attr.get(u'width', 0)) / TILESIZE); + h = int(int(attr.get(u'height', 0)) / TILESIZE); # I'm not sure exactly what the w/h shrinking is for, # I just copied it out of the old converter. # I know that the x += w/2 is to get centers, though. if obj_type == 'spawn': self.object = Mob() - if w > 1: - w -= 1 - if h > 1: - h -= 1 - x += w/2 - y += h/2 + w = int((w - 1) / 2) + h = int((h - 1) / 2) + if w < 0: + w = 0 + else: + x += w + if h < 0: + h = 0 + else: + y += h elif obj_type == 'save': self.object = Save() x += w/2 |