check bounds properly when width_width > 1

This commit is contained in:
Starbeamrainbowlabs 2020-05-03 15:15:42 +01:00
parent 90f7819e09
commit bd73860768
Signed by: sbrl
GPG key ID: 1BE5172E637709C2
2 changed files with 9 additions and 9 deletions

View file

@ -60,13 +60,13 @@ if #settings.extras > 0 then
end
local new_width = calculations.normalise_dimension(settings.width, settings.path_length, settings.path_width)
print("[normalise] width "..settings.width..""..new_width)
settings.width = new_width
local new_height = calculations.normalise_dimension(settings.height, settings.path_length, settings.path_width)
print("[normalise] height "..settings.height..""..new_height)
settings.height = new_height
-- local new_width = calculations.normalise_dimension(settings.width, settings.path_length, settings.path_width)
-- print("[normalise] width "..settings.width.." → "..new_width)
-- settings.width = new_width
--
-- local new_height = calculations.normalise_dimension(settings.height, settings.path_length, settings.path_width)
-- print("[normalise] height "..settings.height.." → "..new_height)
-- settings.height = new_height
local function help()
print([[

View file

@ -69,7 +69,7 @@ function M.generate_maze(seed, width, height, path_length, path_width)
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 and world[cy + path_length][cx] == "#" then
if cy + path_length < height-path_width 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
@ -77,7 +77,7 @@ function M.generate_maze(seed, width, height, path_length, path_width)
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 and world[cy][cx + path_length] == "#" then
if cx + path_length < width-path_width 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