summaryrefslogtreecommitdiff
path: root/misc
diff options
context:
space:
mode:
authorJesusaves <cpntb1@ymail.com>2020-07-09 12:57:02 -0300
committerJesusaves <cpntb1@ymail.com>2020-07-09 12:57:02 -0300
commit4ecbb4ba9f15eedefdfc7e3a2e5e03677ad6f13c (patch)
treedca08036f06c59c5f0f50ec865efee6663f462fe /misc
parent52fb6fb7dc462a0045c54234b78652ce9297eee9 (diff)
downloadtools-4ecbb4ba9f15eedefdfc7e3a2e5e03677ad6f13c.tar.gz
tools-4ecbb4ba9f15eedefdfc7e3a2e5e03677ad6f13c.tar.bz2
tools-4ecbb4ba9f15eedefdfc7e3a2e5e03677ad6f13c.tar.xz
tools-4ecbb4ba9f15eedefdfc7e3a2e5e03677ad6f13c.zip
Generate L/R margins
Diffstat (limited to 'misc')
-rwxr-xr-xmisc/maze.py14
1 files changed, 13 insertions, 1 deletions
diff --git a/misc/maze.py b/misc/maze.py
index 9a2c2d7..19b02b2 100755
--- a/misc/maze.py
+++ b/misc/maze.py
@@ -1,4 +1,5 @@
#!/usr/bin/python2
+# TODO: Automatic 20x20 margins
import numpy
from numpy.random import randint as rand
@@ -10,6 +11,12 @@ def tile():
1,1,1,1,1,2,1,1,1,1,1,1,1,1,1,1,1,2,1,1,1,1,10]
return str(tiles[rand(len(tiles))])
+def block20(txt=True):
+ if txt:
+ return "5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,";
+ else:
+ return [5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5];
+
def generate_maze(width=81, height=51, complexity=.75, density=.75):
"""Generate a maze using a maze generation algorithm."""
# Only odd shapes
@@ -130,12 +137,17 @@ while MazeID < MaxMazes:
MAZEDATA=""
for line in TRUEMAZE:
if line != []:
- MAZEDATA+=(str(line).replace('[','').replace(']','').replace(' ','')+",\n")
+ MAZEDATA+=block20()
+ MAZEDATA+=(str(line).replace('[','').replace(']','').replace(' ',''))
+ MAZEDATA+=","+block20()+"\n"
# Clean MAZEDATA properly
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
+
# Write the TMX file
f.write("""<?xml version="1.0" encoding="UTF-8"?>
<map version="1.0" tiledversion="1.0.3" orientation="orthogonal" renderorder="right-down" width="%d" height="%d" tilewidth="32" tileheight="32" nextobjectid="1">