diff options
author | davidovski <david@davidovski.xyz> | 2024-04-23 18:45:25 +0100 |
---|---|---|
committer | davidovski <david@davidovski.xyz> | 2024-04-23 18:45:25 +0100 |
commit | 69db833ebae7a426fb60d117c67f0b83632618d8 (patch) | |
tree | f32e32ffb4bd5b6177855c5dc9f1b5e00ed8a8fc /levelgen.py | |
parent | 59ac5318648ae3abe62641deec66c64e1728c973 (diff) |
add two more levels
Diffstat (limited to 'levelgen.py')
-rwxr-xr-x | levelgen.py | 95 |
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("}, ") |