summaryrefslogtreecommitdiff
path: root/misc
diff options
context:
space:
mode:
authorJesusaves <cpntb1@ymail.com>2020-07-09 13:06:36 -0300
committerJesusaves <cpntb1@ymail.com>2020-07-09 13:06:36 -0300
commitb563e1a8bf26856af4870640457067eda7d229d7 (patch)
tree5220de350597264dd5b87c053c09ee6d209f6c79 /misc
parent4ecbb4ba9f15eedefdfc7e3a2e5e03677ad6f13c (diff)
downloadtools-b563e1a8bf26856af4870640457067eda7d229d7.tar.gz
tools-b563e1a8bf26856af4870640457067eda7d229d7.tar.bz2
tools-b563e1a8bf26856af4870640457067eda7d229d7.tar.xz
tools-b563e1a8bf26856af4870640457067eda7d229d7.zip
Mazes created will now come with 20x20 margins perfectly
Diffstat (limited to 'misc')
-rwxr-xr-xmisc/maze.py30
1 files changed, 22 insertions, 8 deletions
diff --git a/misc/maze.py b/misc/maze.py
index 19b02b2..3dc4e62 100755
--- a/misc/maze.py
+++ b/misc/maze.py
@@ -113,7 +113,7 @@ def BuildLayer(LayerName, w, h, LayerData, invisible=False):
<data encoding="csv">
%s
</data>
- </layer>""" % (LayerName, w, (h+1)*3, inv, LayerData))
+ </layer>""" % (LayerName, w, h, inv, LayerData))
# Begin
print "Begin!"
@@ -133,20 +133,34 @@ while MazeID < MaxMazes:
f=open(name, "w");
print("open // %s" % name)
+ # Generate Margins
+ MZLINE=str(TRUEMAZE[0]).replace('[','').replace(']','').replace(' ','').replace("10", "5").replace("1", "5").replace("2", "5")+","
+ MARGIN=""
+ i=0
+ while i < 20:
+ i+=1
+ MARGIN+=block20()+MZLINE+block20()+"\n"
+
# Create the maze string
MAZEDATA=""
+ MAZEDATA+=MARGIN
+
+ # Fill maze data
for line in TRUEMAZE:
if line != []:
MAZEDATA+=block20()
MAZEDATA+=(str(line).replace('[','').replace(']','').replace(' ',''))
MAZEDATA+=","+block20()+"\n"
# Clean MAZEDATA properly
+ MAZEDATA+=MARGIN
MAZEDATA=MAZEDATA[:-2]+"\n"
#MAZEMPTY=MAZEDATA.replace("10", "1").replace("2", "1").replace("5", "0")
MAZEMPTY=MAZEDATA.replace("10", "0").replace("1", "0").replace("2", "0").replace("5", "0")[:-1]
# Margin fix
width+=40
+ height=((y+1)*3)+40
+ y+=40
# Write the TMX file
f.write("""<?xml version="1.0" encoding="UTF-8"?>
@@ -158,19 +172,19 @@ while MazeID < MaxMazes:
<tileset firstgid="1" name="set_cave" tilewidth="32" tileheight="32" tilecount="64" columns="8">
<image source="../Rules/tilesets/set_cave.png" width="256" height="256"/>
</tileset>
- """ % (width, (y+1)*3))
+ """ % (width, height))
# Build set layer
- f.write(BuildLayer("set", width, y, MAZEDATA))
+ f.write(BuildLayer("set", width, height, MAZEDATA))
# Build the other tile layers
- f.write(BuildLayer("Ground", width, y, MAZEMPTY))
- f.write(BuildLayer("Fringe", width, y, MAZEMPTY))
- f.write(BuildLayer("Over", width, y, MAZEMPTY))
+ f.write(BuildLayer("Ground", width, height, MAZEMPTY))
+ f.write(BuildLayer("Fringe", width, height, MAZEMPTY))
+ f.write(BuildLayer("Over", width, height, MAZEMPTY))
# Build the other invisible layers
- f.write(BuildLayer("Collision", width, y, MAZEMPTY, True))
- f.write(BuildLayer("Heights", width, y, MAZEMPTY, True))
+ f.write(BuildLayer("Collision", width, height, MAZEMPTY, True))
+ f.write(BuildLayer("Heights", width, height, MAZEMPTY, True))
# Close the mapfile
f.write(""" <objectgroup name="Objects"/>