summaryrefslogtreecommitdiff
path: root/levelgen.py
diff options
context:
space:
mode:
Diffstat (limited to 'levelgen.py')
-rwxr-xr-xlevelgen.py95
1 files changed, 95 insertions, 0 deletions
diff --git a/levelgen.py b/levelgen.py
new file mode 100755
index 0000000..7e2e270
--- /dev/null
+++ b/levelgen.py
@@ -0,0 +1,95 @@
+#!/usr/bin/env python
+array = [
+ "#########################",
+ "#########################",
+ "#########################",
+ "#########################",
+ "#########################",
+ "#########################",
+ "#########################",
+ " ",
+ " ",
+ " ",
+ " ##### ##### ",
+ " ##### ## ##### ",
+ " ##### ## ##### ",
+ " ##### ## ##### ",
+ " ##### ## ##### ",
+ " ##### ## ##### ",
+ " ##### ## ##### ",
+ ]
+#array = [
+# " ",
+# " ",
+# " ",
+# " ",
+# " ################### ",
+# " ################### ",
+# " ## ",
+# " ## ",
+# " ## ",
+# " ## ",
+# " ## ",
+# " ## ",
+# " ## ",
+# " ######## ####### ",
+# " ######## ######## ",
+# " ######## ######## ",
+# " ######## ######## ",
+# ]
+
+def layer0(x, y, solid, topSurface, left, right):
+
+ n = 0
+ if solid and not topSurface:
+ n = 37
+ n += x % 3
+ n += (y % 3)*16
+
+ if topSurface and solid:
+ n = 34
+ if left:
+ n += 16
+ elif right:
+ n += 32
+
+ print ("%d, " % n, end="")
+
+def layer1(x, y, solid, topSurface, left, right):
+
+ n = 0
+ if topSurface and solid:
+ n = 82
+ if left:
+ n += 16
+ elif right:
+ n += 32
+
+ print ("%d, " % n, end="")
+
+
+def calc(x, y):
+
+ solid = array[y][x] == "#"
+
+ topSurface = solid and (y != 0 and array[y-1][x] == " ")
+ left = x == 0 or array[y][x-1] == " "
+ right = (x+1) == len(array[0]) or array[y][x+1] == " "
+ return solid, topSurface, left, right
+
+print("{")
+for y in range(len(array)):
+ for x in range(len(array[y])):
+ solid, topSurface, left, right = calc(x, y)
+ layer0(x, y, solid, topSurface, left, right)
+
+ print("")
+print("}, ")
+print("{")
+for y in range(len(array)):
+ for x in range(len(array[y])):
+ solid, topSurface, left, right = calc(x, y)
+ layer1(x, y, solid, topSurface, left, right)
+
+ print("")
+print("}, ")