Adds light tiles to layout files and a shopkeeper

Next step is to add game logic for shopkeeper murderers and
ability to take items after the shopkeeper is dead.
This commit is contained in:
Linus Probert 2019-03-07 20:06:04 +01:00
parent 447c1a773c
commit 3ba33d8852
5 changed files with 55 additions and 30 deletions

View File

@ -2,6 +2,7 @@ local random = map_random
local pits = {}
local walls = {}
local fences = {}
local lights = {}
local function readLayoutFile(file)
local layoutfile = read_file(file)
@ -29,16 +30,29 @@ local function readLayoutFile(file)
return matrix;
end
local function getTileStateFor(matrix, i, j, c)
local above = matrix[i][j-1] == c;
local below = matrix[i][j+1] == c;
local left = matrix[i-1][j] == c;
local right = matrix[i+1][j] == c;
local function has_value(list, char)
for _, value in ipairs(list) do
if value == char then return true end
end
return false
end
local above_left = matrix[i-1][j-1] == c;
local above_right = matrix[i+1][j-1] == c;
local below_left = matrix[i-1][j+1] == c;
local below_right = matrix[i+1][j+1] == c;
local function getTileStateFor(matrix, i, j, c)
local charList
if type(c) == "string" then
charList = { c }
else
charList = c
end
local above = has_value(charList, matrix[i][j-1])
local below = has_value(charList, matrix[i][j+1])
local left = has_value(charList, matrix[i-1][j])
local right = has_value(charList, matrix[i+1][j])
local above_left = has_value(charList, matrix[i-1][j-1])
local above_right = has_value(charList, matrix[i+1][j-1])
local below_left = has_value(charList, matrix[i-1][j+1])
local below_right = has_value(charList, matrix[i+1][j+1])
return above, below, left, right, above_left, above_right, below_left, below_right
end
@ -115,6 +129,8 @@ function module.load_textures(map, wall_xoffset, wall_yoffset)
local t_pit1 = add_texture(map, "Objects/Pit1.png")
local t_wall = add_texture(map, "Objects/Wall.png")
local t_fence = add_texture(map, "Objects/Fence.png")
local t_decor0 = add_texture(map, "Objects/Decor0.png")
local t_decor1 = add_texture(map, "Objects/Decor1.png")
local yo = (random(5) + random(3)) * (16 * 2)
pits = {
@ -149,7 +165,7 @@ function module.load_textures(map, wall_xoffset, wall_yoffset)
bottom_t = { t_wall, nil, xo + 64, yo + 32, true },
}
yo = 48
yo = 48 * random(3)
fences = {
topleft = { t_fence, nil, 0, yo, true },
top = { t_fence, nil, 16, yo, true },
@ -165,6 +181,11 @@ function module.load_textures(map, wall_xoffset, wall_yoffset)
right_t = { t_fence, nil, 80, yo + 16, true },
bottom_t = { t_fence, nil, 64, yo + 32, true },
}
lights = {
candle0 = { t_decor0, t_decor1, 3 * 16, 8 * 16, true, true },
candle1 = { t_decor0, t_decor1, 1 * 16, 8 * 16, true, true }
}
end
function draw_layout_to_room(room, matrix, roomx, roomy)
@ -175,11 +196,16 @@ function draw_layout_to_room(room, matrix, roomx, roomy)
if matrix[i][j] == "p" then
setPitTile(room, matrix, i, j);
elseif matrix[i][j] == "#" then
setBlockTile(room, matrix, i, j, walls, "#", false)
setBlockTile(room, matrix, i, j, walls, {"#", "\""}, false)
elseif matrix[i][j] == "\"" then
setBlockTile(room, matrix, i, j, walls, {"#", "\""}, false)
room.decor[i][j] = lights.candle1
elseif matrix[i][j] == "f" then
setBlockTile(room, matrix, i, j, fences, "f", true)
elseif matrix[i][j] == "a" then
create_shop_artifact(map, (roomx*512) + i*32, (roomy * 384) + j*32)
elseif matrix[i][j] == "l" then
room.decor[i][j] = lights.candle0
end
end
end

View File

@ -128,7 +128,7 @@ local function generate_path ()
for j=1,10 do
room = map_matrix[i][j]
if room then
if roomCount > 3 and shopLevel and not shopAdded then
if roomCount > 5 and shopLevel and not shopAdded then
room.type = "shop"
shopAdded = true
end
@ -138,6 +138,8 @@ local function generate_path ()
monster_gen.add_monsters_to_room(room, i-1, j-1)
trap_gen.add_traps_to_room(room, i-1, j-1)
chest_gen.add_chests_to_room(room, i-1, j-1)
else
monster_gen.add_shopkeeper_to_room(room, i-1, j-1)
end
if roomCount > 3 and bossLevel and not bossAdded then
bossAdded = true

View File

@ -113,7 +113,7 @@ local stats = {
atk = 2,
def = 0,
speed = 1
}
},
}
local function concat(table1, table2)
@ -279,11 +279,11 @@ for i=1,#eastereggs do
end
local shopkeeper = {
texturePaths.humanoid0,
texturePaths.humanoid1,
texturePaths.humanoid2,
stats.shopkeeper,
12*16,
16,
12*16,
"The Trader",
behaviour.passive
}

View File

@ -1,12 +1,12 @@
++++++++++++++++
++++++++++++++++
++##ffffffff##++
++##--------##++
++#"--------"#++
++f---a--a---f++
++-----------f++
++-----------f++
++f---a--a---f++
++##--------##++
++#"--------"#++
++##ffffffff##++
++++++++++++++++
++++++++++++++++
@ -15,25 +15,25 @@
++++++++++++++++
++ffff----ffff++
++fppf-a--fppf++
++ffff----ffff++
++ffff--l-ffff++
++------a-----++
++------------++
++ffff-a--ffff++
++fppf----fppf++
++fppf-l--fppf++
++ffff--a-ffff++
++++++++++++++++
++++++++++++++++
++++++++++++++++
++++++++++++++++
++############++
++###########"++
++#----------#++
++#-########-#++
++#-####"###-#++
++--#aa--aa#-#++
++--#--------#++
++#-########-#++
++#-####"###-#++
++#----------#++
++############++
++"###########++
++++++++++++++++
++++++++++++++++
@ -41,10 +41,10 @@
++++++++++++++++
++--pppppppp--++
++--pffffffp--++
++--pf---afp--++
++--pfl--afp--++
++-------afp--++
++-------afp--++
++--pf---afp--++
++--pfl--afp--++
++--pffffffp--++
++--pppppppp--++
++++++++++++++++
@ -55,8 +55,8 @@
++pppppppppppp++
++ppffffffffpp++
++fffa----afff++
++------------++
++------------++
++------l-----++
++-----l------++
++fffa----afff++
++ppffffffffpp++
++pppppppppppp++

View File

@ -350,9 +350,6 @@ startGame(void)
if (gPlayer)
player_destroy(gPlayer);
gPlayer = player_create(playerClass, gCamera);
#ifdef DEBUG
gPlayer->gold = 400;
#endif
mixer_play_music(GAME_MUSIC0 + get_random(2));
resetGame();
skillbar_reset(gSkillBar);