diff options
-rwxr-xr-x | misc/maze.py | 30 |
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"/> |