fix bug where maze doesn't generate to the end of the area

Ref 
6e89fc868f
This commit is contained in:
Starbeamrainbowlabs 2021-12-26 23:18:42 +00:00
parent 9e7e4b64ac
commit a65bae20c6
Signed by: sbrl
GPG key ID: 1BE5172E637709C2

View file

@ -60,7 +60,7 @@ end
-- Initialise the world
function M.generate_maze(seed, width, height, path_length, path_width, branching_factor)
start_time = os.clock()
local start_time = os.clock()
if not path_length then path_length = 2 end
if not path_width then path_width = 1 end
@ -95,7 +95,7 @@ function M.generate_maze(seed, width, height, path_length, path_width, branching
directions = directions .. "u"
-- print("up | cy: "..cy..", target: "..cy-path_length..", value: '"..world[cy - path_length][cx].."', path_length: "..path_length)
end
if cy + path_length < height-path_width and world[cy + path_length][cx] == "#" then
if cy + path_length < height-path_width+1 and world[cy + path_length][cx] == "#" then
directions = directions .. "d"
-- print("down | cy: "..cy..", target: "..cy+path_length..", value: '"..world[cy + path_length][cx].."', path_length: "..path_length)
end
@ -103,7 +103,7 @@ function M.generate_maze(seed, width, height, path_length, path_width, branching
directions = directions .. "l"
-- print("left | cx: "..cx..", target: "..cx-path_length..", value: '"..world[cy][cx - path_length].."', path_length: "..path_length)
end
if cx + path_length < width-path_width and world[cy][cx + path_length] == "#" then
if cx + path_length < width-path_width+1 and world[cy][cx + path_length] == "#" then
directions = directions .. "r"
-- print("right | cx: "..cx..", target: "..cx+path_length..", value: '"..world[cy][cx + path_length].."', path_length: "..path_length)
end