summaryrefslogtreecommitdiff
path: root/hercules/maptool.py
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2014-10-05 00:30:36 +0300
committerAndrei Karas <akaras@inbox.ru>2014-10-05 00:30:36 +0300
commit425e121eeacc94057a7620db6f0030c4e9e49f3d (patch)
tree0a1c1c877c801416a2882aaaef764775aadcee29 /hercules/maptool.py
parent6f8dd2e9450befa9632ebcee1086c2095ee0aeae (diff)
downloadevol-tools-425e121eeacc94057a7620db6f0030c4e9e49f3d.tar.gz
evol-tools-425e121eeacc94057a7620db6f0030c4e9e49f3d.tar.bz2
evol-tools-425e121eeacc94057a7620db6f0030c4e9e49f3d.tar.xz
evol-tools-425e121eeacc94057a7620db6f0030c4e9e49f3d.zip
hercules: add support for water in tmx maps.
Diffstat (limited to 'hercules/maptool.py')
-rwxr-xr-xhercules/maptool.py41
1 files changed, 27 insertions, 14 deletions
diff --git a/hercules/maptool.py b/hercules/maptool.py
index e965802..c6917d7 100755
--- a/hercules/maptool.py
+++ b/hercules/maptool.py
@@ -73,26 +73,38 @@ def readFile(path):
with open(path, "r") as f:
return f.read()
-def getTile(mapData, x, y, sx):
+def getTileData(mapData, x, y, sx):
data = mapData[y * sx + x]
arr = array.array("B")
arr.fromstring(data)
data = arr[0]
+ return data
+
+def getTile(data):
+ normal = 0
+ collison = 0
if data == 0: # 000 normal walkable
- data = 0
+ normal = 1
+ collision = 5
elif data == 1: # 001 non walkable
- data = 1
+ normal = 2
+ collision = 6
elif data == 2: # 010 same with 0
- data = 0
+ normal = 1
+ collision = 5
elif data == 3: # 011 same with 0, but water
- data = 0
+ normal = 3
+ collision = 5
elif data == 4: # 100 same with 0
- data = 0
+ normal = 1
+ collision = 5
elif data == 5: # 101 same with 1, but shootable (for now not supported!!!)
- data = 1
+ normal = 4
+ collision = 6
elif data == 6: # 110 same with 0
- data = 0
- return data
+ normal = 1
+ collision = 5
+ return (str(normal), str(collision))
def getGroundTile(flag):
return str(flag + 1)
@@ -191,14 +203,15 @@ def covertToTmx(f, mapsCount):
fringe = ""
for y in xrange(0, sy):
for x in xrange(0, sx):
- tile = getTile(mapData, x, y, sx)
+ tileData = getTileData(mapData, x, y, sx)
+ tile = getTile(tileData)
if x + 1 == sx and y + 1 == sy:
- ground = ground + getGroundTile(tile)
- collision = collision + getCollisionTile(tile)
+ ground = ground + tile[0]
+ collision = collision + tile[1]
fringe = fringe + "0";
else:
- ground = ground + getGroundTile(tile) + ","
- collision = collision + getCollisionTile(tile) + ","
+ ground = ground + tile[0] + ","
+ collision = collision + tile[1] + ","
fringe = fringe + "0,";
ground = ground + "\n"
collision = collision + "\n"