summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xhercules/maptool.py41
-rw-r--r--hercules/templates/template.tmx2
2 files changed, 28 insertions, 15 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"
diff --git a/hercules/templates/template.tmx b/hercules/templates/template.tmx
index 40d8d14..ec9b214 100644
--- a/hercules/templates/template.tmx
+++ b/hercules/templates/template.tmx
@@ -4,7 +4,7 @@
<tileset firstgid="1" name="tiles" tilewidth="32" tileheight="32">
<image source="../graphics/tilesets/tileset.png" width="64" height="32"/>
</tileset>
- <tileset firstgid="3" name="Collision" tilewidth="32" tileheight="32">
+ <tileset firstgid="5" name="Collision" tilewidth="32" tileheight="32">
<image source="../graphics/tilesets/collision.png" width="64" height="32"/>
</tileset>
<layer name="ground" width="{0}" height="{1}">