2017-12-08 09:45:57 +01:00
|
|
|
-- FUNCTIONS
|
|
|
|
local random = math.random
|
|
|
|
|
2017-12-06 17:00:51 +01:00
|
|
|
-- CONSTANTS
|
2017-12-07 23:58:29 +01:00
|
|
|
local UP = 1
|
|
|
|
local LEFT = 2
|
|
|
|
local RIGHT = 3
|
|
|
|
local DOWN = 4
|
2017-12-06 17:00:51 +01:00
|
|
|
|
2017-12-07 23:58:29 +01:00
|
|
|
local floor = {
|
|
|
|
center = nil,
|
|
|
|
top = nil,
|
|
|
|
bottom = nil,
|
|
|
|
left = nil,
|
|
|
|
right = nil,
|
|
|
|
topleft = nil,
|
|
|
|
topright = nil,
|
|
|
|
bottomleft = nil,
|
2017-12-08 09:45:57 +01:00
|
|
|
bottomright = nil
|
2017-12-07 23:58:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
local wall = {
|
|
|
|
topleft = nil,
|
|
|
|
topright = nil,
|
|
|
|
bottomleft = nil,
|
|
|
|
bottomright = nil,
|
|
|
|
vertical = nil,
|
|
|
|
horizontal = nil
|
|
|
|
}
|
2017-12-06 16:02:50 +01:00
|
|
|
|
2017-12-22 06:27:58 +01:00
|
|
|
local special = { level_exit = nil }
|
|
|
|
|
2017-12-08 09:45:57 +01:00
|
|
|
local floorDecor = { }
|
2017-12-11 11:53:18 +01:00
|
|
|
local lightDecor = { }
|
2017-12-08 09:45:57 +01:00
|
|
|
|
2017-12-08 14:40:33 +01:00
|
|
|
local function load_decor_textures()
|
|
|
|
td0 = add_texture(map, "assets/Objects/Decor0.png")
|
|
|
|
td1 = add_texture(map, "assets/Objects/Decor1.png")
|
2017-12-08 09:45:57 +01:00
|
|
|
|
|
|
|
-- Skulls
|
2017-12-10 19:51:24 +01:00
|
|
|
table.insert(floorDecor, { td0, td1, 0, 12 * 16, false, false })
|
|
|
|
table.insert(floorDecor, { td0, td1, 32, 12 * 16, false, false })
|
|
|
|
table.insert(floorDecor, { td0, td1, 64, 12 * 16, false, true })
|
|
|
|
table.insert(floorDecor, { td0, td1, 0, 13 * 16, false, false })
|
|
|
|
table.insert(floorDecor, { td0, td1, 32, 13 * 16, false, false })
|
|
|
|
table.insert(floorDecor, { td0, td1, 64, 13 * 16, false, true })
|
2017-12-08 09:45:57 +01:00
|
|
|
|
|
|
|
-- Bones
|
2017-12-10 19:51:24 +01:00
|
|
|
table.insert(floorDecor, { td0, td1, 16, 12 * 16, false, false })
|
|
|
|
table.insert(floorDecor, { td0, td1, 48, 12 * 16, false, false })
|
|
|
|
table.insert(floorDecor, { td0, td1, 16, 13 * 16, false, false })
|
|
|
|
table.insert(floorDecor, { td0, td1, 48, 13 * 16, false, false })
|
2017-12-08 09:45:57 +01:00
|
|
|
|
|
|
|
-- Urns
|
2017-12-10 19:51:24 +01:00
|
|
|
table.insert(floorDecor, { td0, td1, 0 * 16, 48, true, false })
|
|
|
|
table.insert(floorDecor, { td0, td1, 1 * 16, 48, true, false })
|
|
|
|
table.insert(floorDecor, { td0, td1, 2 * 16, 48, true, false })
|
|
|
|
table.insert(floorDecor, { td0, td1, 3 * 16, 48, true, false })
|
|
|
|
table.insert(floorDecor, { td0, td1, 4 * 16, 48, true, false })
|
|
|
|
table.insert(floorDecor, { td0, td1, 5 * 16, 48, true, false })
|
|
|
|
table.insert(floorDecor, { td0, td1, 6 * 16, 48, false, false })
|
|
|
|
table.insert(floorDecor, { td0, td1, 7 * 16, 48, false, false })
|
2017-12-08 09:45:57 +01:00
|
|
|
|
2017-12-08 12:27:36 +01:00
|
|
|
-- Racks
|
2017-12-10 19:51:24 +01:00
|
|
|
table.insert(floorDecor, { td0, td1, 0 * 16, 11 * 16, true, false })
|
|
|
|
table.insert(floorDecor, { td0, td1, 1 * 16, 11 * 16, true, false })
|
|
|
|
table.insert(floorDecor, { td0, td1, 2 * 16, 11 * 16, true, false })
|
|
|
|
table.insert(floorDecor, { td0, td1, 3 * 16, 11 * 16, true, false })
|
|
|
|
table.insert(floorDecor, { td0, td1, 4 * 16, 11 * 16, true, false })
|
|
|
|
table.insert(floorDecor, { td0, td1, 5 * 16, 11 * 16, true, false })
|
|
|
|
table.insert(floorDecor, { td0, td1, 6 * 16, 11 * 16, true, false })
|
2017-12-08 12:27:36 +01:00
|
|
|
|
2017-12-08 09:45:57 +01:00
|
|
|
-- Headstones
|
2017-12-10 19:51:24 +01:00
|
|
|
table.insert(floorDecor, { td0, td1, 0 * 16, 17 * 16, true, false })
|
|
|
|
table.insert(floorDecor, { td0, td1, 1 * 16, 17 * 16, true, false })
|
|
|
|
table.insert(floorDecor, { td0, td1, 2 * 16, 17 * 16, true, false })
|
|
|
|
table.insert(floorDecor, { td0, td1, 3 * 16, 17 * 16, true, false })
|
|
|
|
table.insert(floorDecor, { td0, td1, 4 * 16, 17 * 16, true, false })
|
|
|
|
table.insert(floorDecor, { td0, td1, 0 * 16, 18 * 16, true, false })
|
|
|
|
table.insert(floorDecor, { td0, td1, 1 * 16, 18 * 16, true, false })
|
|
|
|
table.insert(floorDecor, { td0, td1, 2 * 16, 18 * 16, true, false })
|
|
|
|
table.insert(floorDecor, { td0, td1, 3 * 16, 18 * 16, true, false })
|
|
|
|
table.insert(floorDecor, { td0, td1, 4 * 16, 18 * 16, true, false })
|
2017-12-08 14:40:33 +01:00
|
|
|
|
|
|
|
-- Altars
|
2017-12-10 19:51:24 +01:00
|
|
|
table.insert(floorDecor, { td0, td1, 0 * 16, 20 * 16, true, false })
|
|
|
|
table.insert(floorDecor, { td0, td1, 1 * 16, 20 * 16, true, false })
|
|
|
|
table.insert(floorDecor, { td0, td1, 2 * 16, 20 * 16, true, false })
|
2017-12-08 09:45:57 +01:00
|
|
|
|
|
|
|
-- Webs
|
2017-12-08 14:40:33 +01:00
|
|
|
--table.insert(floorDecor, { td0, td1, 0 * 16, 19 * 16, false })
|
|
|
|
--table.insert(floorDecor, { td0, td1, 1 * 16, 19 * 16, false })
|
|
|
|
--table.insert(floorDecor, { td0, td1, 2 * 16, 19 * 16, false })
|
|
|
|
--table.insert(floorDecor, { td0, td1, 3 * 16, 19 * 16, false })
|
|
|
|
--table.insert(floorDecor, { td0, td1, 4 * 16, 19 * 16, false })
|
|
|
|
|
|
|
|
-- Statues
|
|
|
|
--table.insert(floorDecor, { td0, td1, 3 * 16, 20 * 16, true })
|
|
|
|
--table.insert(floorDecor, { td0, td1, 4 * 16, 20 * 16, true })
|
2017-12-11 11:53:18 +01:00
|
|
|
|
|
|
|
lightDecor.candle0 = { td0, td1, 0, 8 * 16, false, true }
|
|
|
|
lightDecor.candle1 = { td0, td1, 16, 8 * 16, false, true }
|
|
|
|
lightDecor.candle2 = { td0, td1, 32, 8 * 16, true, true }
|
2017-12-08 14:40:33 +01:00
|
|
|
end
|
2017-12-08 09:45:57 +01:00
|
|
|
|
2017-12-22 06:27:58 +01:00
|
|
|
local function load_special_tiles()
|
|
|
|
tt = add_texture(map, "assets/Objects/Tile.png")
|
|
|
|
special.level_exit = { tt, -1, 16, 16, false, true, true }
|
|
|
|
end
|
|
|
|
|
2017-12-10 19:51:24 +01:00
|
|
|
local function repack(data)
|
|
|
|
return {
|
|
|
|
textureIndex0 = data[1],
|
2017-12-22 06:27:58 +01:00
|
|
|
textureIndex1 = data[2] or -1,
|
2017-12-10 19:51:24 +01:00
|
|
|
tileClipX = data[3],
|
|
|
|
tileClipY = data[4],
|
|
|
|
isCollider = data[5] or false,
|
|
|
|
isLightSource = data[6] or false,
|
2017-12-22 06:27:58 +01:00
|
|
|
isLevelExit = data[7] or false,
|
2017-12-10 19:51:24 +01:00
|
|
|
}
|
|
|
|
end
|
|
|
|
|
2018-02-05 16:15:45 +01:00
|
|
|
local function check_add_decoration(map, x, y, data)
|
|
|
|
if tile_occupied(map, x, y) then return end
|
|
|
|
add_decoration(map, x, y, repack(data))
|
|
|
|
end
|
|
|
|
|
2017-12-08 09:45:57 +01:00
|
|
|
local function add_random_decor_to_room()
|
|
|
|
local decor_count = random(4) - 1
|
|
|
|
for i=1,decor_count do
|
2018-02-05 16:15:45 +01:00
|
|
|
check_add_decoration(map, random(11)+1, random(8)+1, floorDecor[random(#floorDecor)])
|
2017-12-08 09:45:57 +01:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2017-12-07 23:58:29 +01:00
|
|
|
local function add_tiles_to_room (map)
|
2017-12-06 16:02:50 +01:00
|
|
|
for i=0,15 do
|
|
|
|
for j=0,11 do
|
|
|
|
if (i >= 1 and i <= 14 and j >= 1 and j <= 10) then
|
|
|
|
if (i == 1 and j == 1) then
|
2017-12-10 19:51:24 +01:00
|
|
|
add_tile(map, i, j, repack(floor.topleft))
|
2017-12-06 16:02:50 +01:00
|
|
|
elseif (i == 14 and j == 1) then
|
2017-12-10 19:51:24 +01:00
|
|
|
add_tile(map, i, j, repack(floor.topright))
|
2017-12-06 16:02:50 +01:00
|
|
|
elseif (i == 1 and j == 10) then
|
2017-12-10 19:51:24 +01:00
|
|
|
add_tile(map, i, j, repack(floor.bottomleft))
|
2017-12-06 16:02:50 +01:00
|
|
|
elseif (i == 14 and j == 10) then
|
2017-12-10 19:51:24 +01:00
|
|
|
add_tile(map, i, j, repack(floor.bottomright))
|
2017-12-06 16:02:50 +01:00
|
|
|
elseif (i == 1) then
|
2017-12-10 19:51:24 +01:00
|
|
|
add_tile(map, i, j, repack(floor.left))
|
2017-12-06 16:02:50 +01:00
|
|
|
elseif (i == 14) then
|
2017-12-10 19:51:24 +01:00
|
|
|
add_tile(map, i, j, repack(floor.right))
|
2017-12-06 16:02:50 +01:00
|
|
|
elseif (j == 1) then
|
2017-12-10 19:51:24 +01:00
|
|
|
add_tile(map, i, j, repack(floor.top))
|
2017-12-06 16:02:50 +01:00
|
|
|
elseif (j == 10) then
|
2017-12-10 19:51:24 +01:00
|
|
|
add_tile(map, i, j, repack(floor.bottom))
|
2017-12-06 16:02:50 +01:00
|
|
|
else
|
2017-12-10 19:51:24 +01:00
|
|
|
add_tile(map, i, j, repack(floor.center))
|
2017-12-06 16:02:50 +01:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2017-12-08 09:45:57 +01:00
|
|
|
|
|
|
|
add_random_decor_to_room()
|
2017-12-06 16:02:50 +01:00
|
|
|
end
|
|
|
|
|
2017-12-07 23:58:29 +01:00
|
|
|
local function add_walls_to_room (map)
|
2017-12-06 16:02:50 +01:00
|
|
|
for i=0,15 do
|
|
|
|
for j=0,11 do
|
|
|
|
if (i == 0 and j == 0) then
|
2017-12-10 19:51:24 +01:00
|
|
|
add_tile(map, i, j, repack(wall.topleft))
|
2017-12-06 16:02:50 +01:00
|
|
|
elseif (i == 15 and j == 0) then
|
2017-12-10 19:51:24 +01:00
|
|
|
add_tile(map, i, j, repack(wall.topright))
|
2017-12-06 16:02:50 +01:00
|
|
|
elseif (i == 0 and j == 11) then
|
2017-12-10 19:51:24 +01:00
|
|
|
add_tile(map, i, j, repack(wall.bottomleft))
|
2017-12-06 16:02:50 +01:00
|
|
|
elseif (i == 15 and j == 11) then
|
2017-12-10 19:51:24 +01:00
|
|
|
add_tile(map, i, j, repack(wall.bottomright))
|
2017-12-06 16:02:50 +01:00
|
|
|
elseif (i == 0 or i == 15) then
|
2017-12-10 19:51:24 +01:00
|
|
|
add_tile(map, i, j, repack(wall.vertical))
|
2017-12-06 16:02:50 +01:00
|
|
|
elseif (j == 0 or j == 11) then
|
2017-12-10 19:51:24 +01:00
|
|
|
add_tile(map, i, j, repack(wall.horizontal))
|
2017-12-06 16:02:50 +01:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2017-12-11 11:53:18 +01:00
|
|
|
|
|
|
|
if random(2) == 1 then
|
2018-02-05 16:15:45 +01:00
|
|
|
check_add_decoration(map, 4, 3, lightDecor.candle2)
|
2017-12-14 09:48:49 +01:00
|
|
|
end
|
|
|
|
if random(2) == 1 then
|
2018-02-05 16:15:45 +01:00
|
|
|
check_add_decoration(map, 11, 3, lightDecor.candle2)
|
2017-12-14 09:48:49 +01:00
|
|
|
end
|
|
|
|
if random(2) == 1 then
|
2018-02-05 16:15:45 +01:00
|
|
|
check_add_decoration(map, 4, 9, lightDecor.candle2)
|
2017-12-14 09:48:49 +01:00
|
|
|
end
|
|
|
|
if random(2) == 1 then
|
2018-02-05 16:15:45 +01:00
|
|
|
check_add_decoration(map, 11, 9, lightDecor.candle2)
|
2017-12-11 11:53:18 +01:00
|
|
|
end
|
2017-12-06 16:02:50 +01:00
|
|
|
end
|
|
|
|
|
2017-12-07 23:58:29 +01:00
|
|
|
local function add_exit(map, direction)
|
2017-12-06 16:02:50 +01:00
|
|
|
if direction > 4 then return end
|
|
|
|
|
|
|
|
if direction == UP then
|
2017-12-10 19:51:24 +01:00
|
|
|
add_tile(map, 6, 0, repack(wall.bottomright))
|
|
|
|
add_tile(map, 7, 0, repack(floor.singleleft))
|
|
|
|
add_tile(map, 8, 0, repack(floor.singleright))
|
|
|
|
add_tile(map, 9, 0, repack(wall.bottomleft))
|
2017-12-06 16:02:50 +01:00
|
|
|
elseif direction == LEFT then
|
2017-12-10 19:51:24 +01:00
|
|
|
add_tile(map, 0, 4, repack(wall.bottomright))
|
|
|
|
add_tile(map, 0, 5, repack(floor.singletop))
|
|
|
|
add_tile(map, 0, 6, repack(floor.singlebottom))
|
|
|
|
add_tile(map, 0, 7, repack(wall.topright))
|
2017-12-06 16:02:50 +01:00
|
|
|
elseif direction == RIGHT then
|
2017-12-10 19:51:24 +01:00
|
|
|
add_tile(map, 15, 4, repack(wall.bottomleft))
|
|
|
|
add_tile(map, 15, 5, repack(floor.singletop))
|
|
|
|
add_tile(map, 15, 6, repack(floor.singlebottom))
|
|
|
|
add_tile(map, 15, 7, repack(wall.topleft))
|
2017-12-06 16:02:50 +01:00
|
|
|
elseif direction == DOWN then
|
2017-12-10 19:51:24 +01:00
|
|
|
add_tile(map, 6, 11, repack(wall.topright))
|
|
|
|
add_tile(map, 7, 11, repack(floor.singleleft))
|
|
|
|
add_tile(map, 8, 11, repack(floor.singleright))
|
|
|
|
add_tile(map, 9, 11, repack(wall.topleft))
|
2017-12-07 23:58:29 +01:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2017-12-22 06:27:58 +01:00
|
|
|
local function add_level_exit(map)
|
|
|
|
x = random(14)
|
|
|
|
y = random(10)
|
|
|
|
add_tile(map, x, y, repack(special.level_exit));
|
|
|
|
end
|
|
|
|
|
2017-12-07 23:58:29 +01:00
|
|
|
local function build_vert_center_coridoor(map, offset)
|
|
|
|
for j=0,4 do
|
2017-12-10 19:51:24 +01:00
|
|
|
add_tile(map, 6, offset+j, repack(wall.vertical));
|
|
|
|
add_tile(map, 7, offset+j, repack(floor.center));
|
|
|
|
add_tile(map, 8, offset+j, repack(floor.center));
|
|
|
|
add_tile(map, 9, offset+j, repack(wall.vertical));
|
2017-12-07 23:58:29 +01:00
|
|
|
end
|
2017-12-11 11:53:18 +01:00
|
|
|
if random(2) == 1 then
|
2018-02-05 16:15:45 +01:00
|
|
|
check_add_decoration(map, 6, offset + 2, lightDecor.candle1)
|
2017-12-11 11:53:18 +01:00
|
|
|
end
|
|
|
|
if random(2) == 1 then
|
2018-02-05 16:15:45 +01:00
|
|
|
check_add_decoration(map, 9, offset + 2, lightDecor.candle1)
|
2017-12-11 11:53:18 +01:00
|
|
|
end
|
2017-12-07 23:58:29 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
local function build_horiz_center_coridoor(map, offset)
|
|
|
|
for i=0,6 do
|
2017-12-10 19:51:24 +01:00
|
|
|
add_tile(map, offset+i, 4, repack(wall.horizontal));
|
|
|
|
add_tile(map, offset+i, 5, repack(floor.center));
|
|
|
|
add_tile(map, offset+i, 6, repack(floor.center));
|
|
|
|
add_tile(map, offset+i, 7, repack(wall.horizontal));
|
2017-12-07 23:58:29 +01:00
|
|
|
end
|
2017-12-11 11:53:18 +01:00
|
|
|
if random(2) == 1 then
|
2018-02-05 16:15:45 +01:00
|
|
|
check_add_decoration(map, offset+3, 4, lightDecor.candle1)
|
2017-12-11 11:53:18 +01:00
|
|
|
end
|
|
|
|
if random(2) == 1 then
|
2018-02-05 16:15:45 +01:00
|
|
|
check_add_decoration(map, offset+3, 7, lightDecor.candle1)
|
2017-12-11 11:53:18 +01:00
|
|
|
end
|
2017-12-07 23:58:29 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
local function build_center_corner_walls(map, exits)
|
|
|
|
if exits.down then
|
|
|
|
if exits.left then
|
2017-12-10 19:51:24 +01:00
|
|
|
add_tile(map, 6, 7, repack(wall.topright))
|
2017-12-07 23:58:29 +01:00
|
|
|
end
|
|
|
|
if exits.right then
|
2017-12-10 19:51:24 +01:00
|
|
|
add_tile(map, 9, 7, repack(wall.topleft))
|
2017-12-07 23:58:29 +01:00
|
|
|
end
|
|
|
|
else
|
|
|
|
if not exits.left then
|
2017-12-10 19:51:24 +01:00
|
|
|
add_tile(map, 6, 7, repack(wall.bottomleft))
|
2017-12-07 23:58:29 +01:00
|
|
|
end
|
|
|
|
if not exits.right then
|
2017-12-10 19:51:24 +01:00
|
|
|
add_tile(map, 9, 7, repack(wall.bottomright))
|
2017-12-07 23:58:29 +01:00
|
|
|
end
|
|
|
|
end
|
|
|
|
if exits.up then
|
|
|
|
if exits.left then
|
2017-12-10 19:51:24 +01:00
|
|
|
add_tile(map, 6, 4, repack(wall.bottomright))
|
2017-12-07 23:58:29 +01:00
|
|
|
end
|
|
|
|
if exits.right then
|
2017-12-10 19:51:24 +01:00
|
|
|
add_tile(map, 9, 4, repack(wall.bottomleft))
|
2017-12-07 23:58:29 +01:00
|
|
|
end
|
|
|
|
else
|
|
|
|
if not exits.left then
|
2017-12-10 19:51:24 +01:00
|
|
|
add_tile(map, 6, 4, repack(wall.topleft))
|
2017-12-07 23:58:29 +01:00
|
|
|
end
|
|
|
|
if not exits.right then
|
2017-12-10 19:51:24 +01:00
|
|
|
add_tile(map, 9, 4, repack(wall.topright))
|
2017-12-07 23:58:29 +01:00
|
|
|
end
|
2017-12-06 16:02:50 +01:00
|
|
|
end
|
|
|
|
end
|
2017-12-07 23:58:29 +01:00
|
|
|
|
2017-12-11 20:07:05 +01:00
|
|
|
local module = {}
|
|
|
|
|
|
|
|
function module.build_coridoor_room(map, room)
|
2017-12-07 23:58:29 +01:00
|
|
|
local exits = {
|
|
|
|
up = false,
|
|
|
|
down = false,
|
|
|
|
left = false,
|
|
|
|
right = false
|
|
|
|
}
|
|
|
|
|
|
|
|
for _,exit in ipairs(room.exits) do
|
|
|
|
if UP == exit then exits.up = true
|
|
|
|
elseif DOWN == exit then exits.down = true
|
|
|
|
elseif LEFT == exit then exits.left = true
|
|
|
|
elseif RIGHT == exit then exits.right = true
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
-- Fill the center
|
2017-12-10 19:51:24 +01:00
|
|
|
add_tile(map, 6, 5, repack(wall.vertical))
|
|
|
|
add_tile(map, 6, 6, repack(wall.vertical))
|
|
|
|
add_tile(map, 7, 4, repack(wall.horizontal))
|
|
|
|
add_tile(map, 7, 5, repack(floor.center))
|
|
|
|
add_tile(map, 7, 6, repack(floor.center))
|
|
|
|
add_tile(map, 7, 7, repack(wall.horizontal))
|
|
|
|
add_tile(map, 8, 4, repack(wall.horizontal))
|
|
|
|
add_tile(map, 8, 5, repack(floor.center))
|
|
|
|
add_tile(map, 8, 6, repack(floor.center))
|
|
|
|
add_tile(map, 8, 7, repack(wall.horizontal))
|
|
|
|
add_tile(map, 9, 5, repack(wall.vertical))
|
|
|
|
add_tile(map, 9, 6, repack(wall.vertical))
|
2017-12-07 23:58:29 +01:00
|
|
|
|
|
|
|
-- Build the coridoors
|
|
|
|
if exits.down then build_vert_center_coridoor(map, 7) end
|
|
|
|
if exits.up then build_vert_center_coridoor(map, 0) end
|
|
|
|
if exits.left then build_horiz_center_coridoor(map, 0) end
|
|
|
|
if exits.right then build_horiz_center_coridoor(map, 9) end
|
|
|
|
|
|
|
|
build_center_corner_walls(map, exits)
|
|
|
|
end
|
2017-12-11 20:07:05 +01:00
|
|
|
|
|
|
|
function module.create_room ()
|
|
|
|
return {
|
|
|
|
exits = {},
|
|
|
|
active = false,
|
|
|
|
goal = false,
|
|
|
|
path_dir = 0,
|
|
|
|
type = "room"
|
|
|
|
}
|
|
|
|
end
|
|
|
|
|
|
|
|
function module.build_square_room(map, room)
|
|
|
|
add_tiles_to_room(map);
|
|
|
|
add_walls_to_room(map);
|
|
|
|
for exit=1, #room.exits do
|
|
|
|
add_exit(map, room.exits[exit]);
|
|
|
|
end
|
2017-12-22 06:27:58 +01:00
|
|
|
if room.goal then
|
|
|
|
add_level_exit(map);
|
|
|
|
end
|
2017-12-11 20:07:05 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
function module.load_textures(map)
|
|
|
|
t_floor = add_texture(map, "assets/Objects/Floor.png")
|
|
|
|
t_wall = add_texture(map, "assets/Objects/Wall.png")
|
|
|
|
|
|
|
|
math.randomseed(os.time())
|
|
|
|
local xo = (random(3) - 1) * 112
|
|
|
|
local yo = (random(7)) * 48
|
|
|
|
|
|
|
|
floor.center = { t_floor, -1, xo + 16, yo + 16, false }
|
|
|
|
floor.top = { t_floor, -1, xo + 16, yo + 0, false }
|
|
|
|
floor.bottom = { t_floor, -1, xo + 16, yo + 32, false }
|
|
|
|
floor.left = { t_floor, -1, xo + 0, yo + 16, false }
|
|
|
|
floor.right = { t_floor, -1, xo + 32, yo + 16, false }
|
|
|
|
floor.topleft = { t_floor, -1, xo + 0, yo + 0, false }
|
|
|
|
floor.topright = { t_floor, -1, xo + 32, yo + 0, false }
|
|
|
|
floor.bottomleft = { t_floor, -1, xo + 0, yo + 32, false }
|
|
|
|
floor.bottomright = { t_floor, -1, xo + 32, yo + 32, false }
|
|
|
|
floor.singletop = { t_floor, -1, xo + 48, yo + 0, false }
|
|
|
|
floor.singlebottom = { t_floor, -1, xo + 48, yo + 32, false }
|
|
|
|
floor.singleleft = { t_floor, -1, xo + 64, yo + 16, false }
|
|
|
|
floor.singleright = { t_floor, -1, xo + 96, yo + 16, false }
|
|
|
|
|
|
|
|
wall.topleft = { t_wall, -1, xo + 0, yo + 0, true }
|
|
|
|
wall.topright = { t_wall, -1, xo + 32, yo + 0, true }
|
|
|
|
wall.bottomleft = { t_wall, -1, xo + 0, yo + 32, true }
|
|
|
|
wall.bottomright = { t_wall, -1, xo + 32, yo + 32, true }
|
|
|
|
wall.vertical = { t_wall, -1, xo + 0, yo + 16, true }
|
|
|
|
wall.horizontal = { t_wall, -1, xo + 16, yo + 0, true }
|
|
|
|
|
|
|
|
load_decor_textures()
|
2017-12-22 06:27:58 +01:00
|
|
|
load_special_tiles()
|
2017-12-11 20:07:05 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
return module
|