I am trying to port this to godot and having some issues.
Basic idea is that each square on a grid has 2 braille characters that make up shape of walls. It ends up like this:
⡏⠉⠉⠉⣉⣉⣉⣹⡏⠉⣉⣉⣉⣉⣉⣉⣉⣉⠉⢹⡏⠉⣉⣉⣉⣉⣉⣉⣉⣉⣉⣉⣉⣉⣉⣉⣉⣉⠉⢹
⡇⢸⡇⢸⡏⠉⠉⢹⣇⣀⣉⣉⠉⢹⣏⣉⠉⢹⣇⣀⣀⣸⡏⠉⠉⢹⡏⠉⣉⣉⣉⣹⡏⠉⣉⣉⣉⣉⣀⣸
⡇⢸⣇⣀⣀⣸⣇⣀⣉⣉⠉⢹⣇⣀⠉⢹⡇⠀⠉⢹⡏⠉⠀⢸⣇⣀⣀⣸⡏⠉⠉⢹⣇⣀⣉⣉⣉⣉⠉⢹
⡇⢸⣏⣉⣉⣉⠉⢹⡏⠉⣀⣀⠉⢹⣇⣀⣀⣸⡇⢸⣇⣸⡇⠀⣉⣉⣉⣉⣀⣸⣇⣀⣉⣉⠉⠉⣉⣹⡇⢸
⣇⣀⣉⣉⠉⢹⡇⢸⣇⣀⠉⢹⣇⣀⠉⠉⣉⣹⣇⣀⠉⢹⡇⠀⣉⣹⡏⠉⣉⣉⣉⣉⠉⢹⡇⢸⡏⠉⠀⢸
⡏⠉⣉⣹⡇⢸⡇⢸⡏⠉⣀⣸⣏⣉⣀⣸⡏⠉⣉⣉⣀⣸⣇⣸⡏⠉⣀⣸⣏⣉⣉⣉⣀⣀⠀⢸⡇⢸⡇⢸
⡇⠀⣉⣉⣀⣸⡇⢸⡇⢸⡏⠉⣉⣉⣉⣉⣀⣸⣏⣉⠉⠉⣉⣉⣀⣸⡏⠉⣉⣉⣉⣉⠉⢹⡇⢸⡇⢸⡇⢸
⣇⣀⣉⣉⣉⣉⠀⢸⣇⣀⣀⣸⣏⣉⠉⠉⠉⠉⣉⣉⣀⣸⡏⠉⣉⣉⣀⣸⡏⢹⡏⠉⣀⣸⣇⣸⡇⢸⡇⢸
⡏⢹⡏⠉⠉⢹⡇⢸⡏⠉⠉⢹⡏⠉⠀⢸⣇⣸⡏⠉⠉⢹⡇⢸⣏⣉⠉⠉⠀⢸⡇⢸⣏⣉⠉⠉⣀⣸⣇⣸
⡇⢸⡇⢸⣇⣀⣀⣸⡇⢸⡇⠀⣀⣸⣇⣸⡏⠉⣀⣸⣇⣀⣀⣸⡏⠉⣀⣸⣇⣸⣇⣀⠉⢹⣇⣀⣉⣉⠉⢹
⡇⠀⣀⣸⡏⠉⠉⢹⡇⢸⣇⣸⡏⠉⠉⢹⣇⣀⠉⢹⣏⣉⣉⣉⣀⣀⠉⠉⣉⣉⠉⢹⣇⣀⣉⣉⣉⣉⣀⣸
⣇⣀⠉⢹⡇⢸⡇⠀⣀⣸⡏⠉⣀⣸⣇⣀⠉⢹⡇⢸⡏⠉⣉⣉⠉⢹⣇⣀⣉⣹⡇⠀⣉⣉⣉⣉⣉⣉⠉⢹
⡏⢹⣇⣀⣀⣸⡇⢸⣏⣉⣀⣸⣏⣉⠉⢹⣇⣀⣀⣸⡇⢸⣏⣉⣀⣀⣉⣉⠉⢹⡇⢸⡏⠉⠉⢹⡏⠉⣀⣸
⡇⠀⠉⢹⡏⠉⣀⣸⡏⠉⣉⣉⠉⢹⡇⢸⡏⠉⣉⣉⣀⣀⠉⢹⡏⠉⣉⣉⣀⣸⡇⠀⣀⣸⡇⢸⣇⣀⣉⣹
⡇⢸⡇⢸⣇⣀⣉⣉⣀⣸⡏⠉⣀⣸⡇⢸⡇⢸⡏⠉⣉⣹⡇⢸⡇⢸⡏⠉⣉⣹⡇⠀⣉⣹⣇⣀⠉⠉⠉⢹
⡇⢸⣇⣀⣉⣉⣉⣉⣉⣉⣀⣸⡏⠉⣀⣸⡇⠀⣀⣸⡏⠉⣀⣸⡇⢸⣇⣀⣉⣉⣀⣸⡏⠉⠉⢹⣇⣸⡇⢸
⣇⣀⠉⢹⣏⣉⣉⣉⠉⠉⠉⢹⣇⣀⣉⣉⣀⣸⡏⠉⣀⣸⡏⢹⣇⣀⣉⣉⣉⣉⣉⣉⣀⣸⡇⢸⡏⠉⣀⣸
⡏⢹⡇⢸⡏⠉⣉⣉⣀⣸⣇⣀⣉⣉⣉⣉⣉⣉⣀⣸⡏⠉⠀⢸⡏⠉⣉⣉⣉⣉⣉⣉⣉⣉⣀⣸⣇⣀⠉⢹
⡇⢸⡇⢸⡇⢸⡏⠉⣉⣉⣉⣉⠉⢹⡏⠉⣉⣉⣉⣉⠀⢸⣇⣸⡇⢸⡏⠉⣉⣉⠉⢹⣏⣉⠉⠉⣉⣉⠀⢸
⣇⣀⣀⣀⣀⣸⣇⣀⣉⣉⣉⣹⣇⣀⣀⣀⣉⣉⣉⣹⣇⣀⣉⣉⣀⣀⣀⣸⣏⣉⣀⣀⣉⣉⣀⣸⣏⣉⣀⣸
I think I have the maze-representation covered (using an array of int-arrays, with bitmask for closed doors)
My problem is just printing the characters. Here is my code:
# utility function to set an array of bit-flags
func setbits(x, pa):
for p in pa:
var hasbit = fposmod(x, p + p) >= p
x = x if hasbit else x + p
return x
func to_braille():
var result = ""
for y in range(height):
for x in range(width):
var block = [0x2800, 0x2800]
if is_closed(Vector2(x, y), N):
block[0] = setbits(block[0], [0x01, 0x08])
block[1] = setbits(block[1], [0x01, 0x08])
if is_closed(Vector2(x, y), S):
block[0] = setbits(block[0], [0x40, 0x80])
block[1] = setbits(block[1], [0x40, 0x80])
if is_closed(Vector2(x, y), E):
block[1] = setbits(block[1], [0x08, 0x10, 0x20, 0x80])
if is_closed(Vector2(x, y), W):
block[0] = setbits(block[0], [0x01, 0x02, 0x04, 0x40])
result += char(block[0]) + char(block[1])
result += "\n"
return result
I verified the setbits
part is working by printing the block
ints it ends up with then doing String.fromCharCode(10489)
(as an example) in a javascript console, which correctly makes this: ⣹
the problem is that I can't get godot to print these mazes. Is it a limitation of the console? My eventual goal is to put this in a Label
which also seems to not work:
