From b563e1a8bf26856af4870640457067eda7d229d7 Mon Sep 17 00:00:00 2001 From: Jesusaves Date: Thu, 9 Jul 2020 13:06:36 -0300 Subject: Mazes created will now come with 20x20 margins perfectly --- misc/maze.py | 30 ++++++++++++++++++++++-------- 1 file changed, 22 insertions(+), 8 deletions(-) (limited to 'misc') 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): %s - """ % (LayerName, w, (h+1)*3, inv, LayerData)) + """ % (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(""" @@ -158,19 +172,19 @@ while MazeID < MaxMazes: - """ % (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(""" -- cgit v1.2.3-70-g09d2