Fences and walls in layout files
This commit is contained in:
parent
1c4e600dd4
commit
206f95f3b6
|
@ -43,11 +43,44 @@ local function getTileStateFor(matrix, i, j, c)
|
||||||
return above, below, left, right, above_left, above_right, below_left, below_right
|
return above, below, left, right, above_left, above_right, below_left, below_right
|
||||||
end
|
end
|
||||||
|
|
||||||
local function setPitTile(room, matrix, i, j)
|
local function setBlockTile(room, matrix, i, j, tiles, char, decorTiles)
|
||||||
if matrix[i][j] ~= "p" then
|
local above, below, left, right, above_left, above_right, below_left, below_right = getTileStateFor(matrix, i, j, char);
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
|
room.decor[i][j] = nil
|
||||||
|
local tile = nil
|
||||||
|
if above and below and left and right then
|
||||||
|
tile = tiles.cross
|
||||||
|
elseif not above and below and left and right then
|
||||||
|
tile = tiles.top_t
|
||||||
|
elseif not below and above and left and right then
|
||||||
|
tile = tiles.bottom_t
|
||||||
|
elseif not left and above and below and right then
|
||||||
|
tile = tiles.left_t
|
||||||
|
elseif not right and above and below and left then
|
||||||
|
tile = tiles.right_t
|
||||||
|
elseif not above and not left and right and below then
|
||||||
|
tile = tiles.topleft
|
||||||
|
elseif not above and not right and left and below then
|
||||||
|
tile = tiles.topright
|
||||||
|
elseif not below and not left and above and right then
|
||||||
|
tile = tiles.bottomleft
|
||||||
|
elseif not below and not right and above and left then
|
||||||
|
tile = tiles.bottomright
|
||||||
|
elseif not left and not right and below then
|
||||||
|
tile = tiles.left
|
||||||
|
elseif not above and not below and (left or right) then
|
||||||
|
tile = tiles.top
|
||||||
|
else
|
||||||
|
tile = tiles.single
|
||||||
|
end
|
||||||
|
if decorTiles then
|
||||||
|
room.decor[i][j] = tile
|
||||||
|
else
|
||||||
|
room.tiles[i][j] = tile
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
local function setPitTile(room, matrix, i, j)
|
||||||
local above, below, left, right, above_left, above_right, below_left, below_right = getTileStateFor(matrix, i, j, "p");
|
local above, below, left, right, above_left, above_right, below_left, below_right = getTileStateFor(matrix, i, j, "p");
|
||||||
|
|
||||||
room.decor[i][j] = nil
|
room.decor[i][j] = nil
|
||||||
|
@ -102,10 +135,12 @@ function module.load_textures(map)
|
||||||
walls = {
|
walls = {
|
||||||
topleft = { t_wall, nil, 0, yoffset, true },
|
topleft = { t_wall, nil, 0, yoffset, true },
|
||||||
top = { t_wall, nil, 16, yoffset, true },
|
top = { t_wall, nil, 16, yoffset, true },
|
||||||
|
single = { t_wall, nil, 16, yoffset + 16, true },
|
||||||
topright = { t_wall, nil, 32, yoffset, true },
|
topright = { t_wall, nil, 32, yoffset, true },
|
||||||
left = { t_wall, nil, 0, yoffset + 16, true },
|
left = { t_wall, nil, 0, yoffset + 16, true },
|
||||||
bottomleft = { t_wall, nil, 0, yoffset + 32, true },
|
bottomleft = { t_wall, nil, 0, yoffset + 32, true },
|
||||||
bottomright = { t_wall, nil, 32, yoffset + 32, true },
|
bottomright = { t_wall, nil, 32, yoffset + 32, true },
|
||||||
|
center = { t_wall, nil, 48, yoffset, true },
|
||||||
top_t = { t_wall, nil, 64, yoffset, true },
|
top_t = { t_wall, nil, 64, yoffset, true },
|
||||||
left_t = { t_wall, nil, 48, yoffset + 16, true },
|
left_t = { t_wall, nil, 48, yoffset + 16, true },
|
||||||
cross = { t_wall, nil, 64, yoffset + 16, true },
|
cross = { t_wall, nil, 64, yoffset + 16, true },
|
||||||
|
@ -117,10 +152,12 @@ function module.load_textures(map)
|
||||||
fences = {
|
fences = {
|
||||||
topleft = { t_fence, nil, 0, yoffset, true },
|
topleft = { t_fence, nil, 0, yoffset, true },
|
||||||
top = { t_fence, nil, 16, yoffset, true },
|
top = { t_fence, nil, 16, yoffset, true },
|
||||||
|
single = { t_wall, nil, 16, yoffset + 16, true },
|
||||||
topright = { t_fence, nil, 32, yoffset, true },
|
topright = { t_fence, nil, 32, yoffset, true },
|
||||||
left = { t_fence, nil, 0, yoffset + 16, true },
|
left = { t_fence, nil, 0, yoffset + 16, true },
|
||||||
bottomleft = { t_fence, nil, 0, yoffset + 32, true },
|
bottomleft = { t_fence, nil, 0, yoffset + 32, true },
|
||||||
bottomright = { t_fence, nil, 32, yoffset + 32, true },
|
bottomright = { t_fence, nil, 32, yoffset + 32, true },
|
||||||
|
center = { t_fence, nil, 48, yoffset, true },
|
||||||
top_t = { t_fence, nil, 64, yoffset, true },
|
top_t = { t_fence, nil, 64, yoffset, true },
|
||||||
left_t = { t_fence, nil, 48, yoffset + 16, true },
|
left_t = { t_fence, nil, 48, yoffset + 16, true },
|
||||||
cross = { t_fence, nil, 64, yoffset + 16, true },
|
cross = { t_fence, nil, 64, yoffset + 16, true },
|
||||||
|
@ -134,14 +171,25 @@ function module.add_pits_to_room(room)
|
||||||
--return false
|
--return false
|
||||||
--end
|
--end
|
||||||
|
|
||||||
local matrix = readLayoutFile("pitlayouts.dat")
|
local matrix = readLayoutFile("walllayouts.dat")
|
||||||
|
--local matrix = readLayoutFile("pitlayouts.dat")
|
||||||
|
|
||||||
-- Chose a random layout
|
-- Chose a random layout
|
||||||
matrix = matrix[random(#matrix)]
|
matrix = matrix[random(#matrix)]
|
||||||
for i=2,13 do
|
for i=2,13 do
|
||||||
for j=2,10 do
|
for j=2,10 do
|
||||||
setPitTile(room, matrix, i, j);
|
if matrix[i][j] ~= nil then
|
||||||
|
io.write("" .. matrix[i][j])
|
||||||
|
end
|
||||||
|
if matrix[i][j] == "p" then
|
||||||
|
setPitTile(room, matrix, i, j);
|
||||||
|
elseif matrix[i][j] == "#" then
|
||||||
|
setBlockTile(room, matrix, i, j, walls, "#", false)
|
||||||
|
elseif matrix[i][j] == "f" then
|
||||||
|
setBlockTile(room, matrix, i, j, fences, "f", true)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
print("")
|
||||||
end
|
end
|
||||||
|
|
||||||
return true
|
return true
|
||||||
|
|
|
@ -0,0 +1,25 @@
|
||||||
|
----------------
|
||||||
|
----------------
|
||||||
|
--#####---###---
|
||||||
|
--#---#---###---
|
||||||
|
--#--###--###---
|
||||||
|
------#--#------
|
||||||
|
------####------
|
||||||
|
------------#---
|
||||||
|
------------#---
|
||||||
|
---#---####-#---
|
||||||
|
----------------
|
||||||
|
----------------
|
||||||
|
|
||||||
|
----------------
|
||||||
|
----------------
|
||||||
|
--fffff---fff---
|
||||||
|
--f---f---fff---
|
||||||
|
--f--fff--fff---
|
||||||
|
------f--f------
|
||||||
|
------ffff------
|
||||||
|
------------f---
|
||||||
|
------------f---
|
||||||
|
---f---ffff-f---
|
||||||
|
----------------
|
||||||
|
----------------
|
Loading…
Reference in New Issue