fix bug where maze doesn't generate to the end of the area
Ref
6e89fc868f
This commit is contained in:
parent
9e7e4b64ac
commit
a65bae20c6
1 changed files with 3 additions and 3 deletions
6
maze.lua
6
maze.lua
|
@ -60,7 +60,7 @@ end
|
||||||
-- Initialise the world
|
-- Initialise the world
|
||||||
|
|
||||||
function M.generate_maze(seed, width, height, path_length, path_width, branching_factor)
|
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_length then path_length = 2 end
|
||||||
if not path_width then path_width = 1 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"
|
directions = directions .. "u"
|
||||||
-- print("up | cy: "..cy..", target: "..cy-path_length..", value: '"..world[cy - path_length][cx].."', path_length: "..path_length)
|
-- print("up | cy: "..cy..", target: "..cy-path_length..", value: '"..world[cy - path_length][cx].."', path_length: "..path_length)
|
||||||
end
|
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"
|
directions = directions .. "d"
|
||||||
-- print("down | cy: "..cy..", target: "..cy+path_length..", value: '"..world[cy + path_length][cx].."', path_length: "..path_length)
|
-- print("down | cy: "..cy..", target: "..cy+path_length..", value: '"..world[cy + path_length][cx].."', path_length: "..path_length)
|
||||||
end
|
end
|
||||||
|
@ -103,7 +103,7 @@ function M.generate_maze(seed, width, height, path_length, path_width, branching
|
||||||
directions = directions .. "l"
|
directions = directions .. "l"
|
||||||
-- print("left | cx: "..cx..", target: "..cx-path_length..", value: '"..world[cy][cx - path_length].."', path_length: "..path_length)
|
-- print("left | cx: "..cx..", target: "..cx-path_length..", value: '"..world[cy][cx - path_length].."', path_length: "..path_length)
|
||||||
end
|
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"
|
directions = directions .. "r"
|
||||||
-- print("right | cx: "..cx..", target: "..cx+path_length..", value: '"..world[cy][cx + path_length].."', path_length: "..path_length)
|
-- print("right | cx: "..cx..", target: "..cx+path_length..", value: '"..world[cy][cx + path_length].."', path_length: "..path_length)
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue