Nicer exits in rooms

This commit is contained in:
Linus Probert 2017-12-06 17:00:51 +01:00
parent b950673952
commit 171f8c8b5e
3 changed files with 32 additions and 17 deletions

View File

@ -89,16 +89,16 @@ load_textures(map)
local map_matrix = generate_path() local map_matrix = generate_path()
-- Print path [Debug] -- Print path [Debug]
for i=1,10 do --for i=1,10 do
for j=1,10 do --for j=1,10 do
if not map_matrix[j][i].goal then --if not map_matrix[j][i].goal then
io.write(map_matrix[j][i].path_dir .. " ") --io.write(map_matrix[j][i].path_dir .. " ")
else --else
io.write("G ") --io.write("G ")
end --end
end --end
io.write("\n") --io.write("\n")
end --end
for i=1,10 do for i=1,10 do
for j=1,10 do for j=1,10 do

View File

@ -1,3 +1,9 @@
-- CONSTANTS
UP = 1
LEFT = 2
RIGHT = 3
DOWN = 4
-- Textures -- Textures
local floorTexture = nil local floorTexture = nil
local wallTexture = nil local wallTexture = nil
@ -36,12 +42,12 @@ function load_textures(map)
floor_bottomleft = { floorTexture, xo + 0, yo + 32, false } floor_bottomleft = { floorTexture, xo + 0, yo + 32, false }
floor_bottomright = { floorTexture, xo + 32, yo + 32, false } floor_bottomright = { floorTexture, xo + 32, yo + 32, false }
wall_topleft = { wallTexture, xo + 0, yo + 0, false } wall_topleft = { wallTexture, xo + 0, yo + 0, true }
wall_topright = { wallTexture, xo + 32, yo + 0, false } wall_topright = { wallTexture, xo + 32, yo + 0, true }
wall_bottomleft = { wallTexture, xo + 0, yo + 32, false } wall_bottomleft = { wallTexture, xo + 0, yo + 32, true }
wall_bottomright = { wallTexture, xo + 32, yo + 32, false } wall_bottomright = { wallTexture, xo + 32, yo + 32, true }
wall_vertical = { wallTexture, xo + 0, yo + 16, false } wall_vertical = { wallTexture, xo + 0, yo + 16, true }
wall_horizontal = { wallTexture, xo + 16, yo + 0, false } wall_horizontal = { wallTexture, xo + 16, yo + 0, true }
end end
function create_room () function create_room ()
@ -105,16 +111,24 @@ function add_exit(map, direction)
if direction > 4 then return end if direction > 4 then return end
if direction == UP then if direction == UP then
add_tile(map, 6, 0, unpack(wall_bottomright))
add_tile(map, 7, 0, unpack(floor_center)) add_tile(map, 7, 0, unpack(floor_center))
add_tile(map, 8, 0, unpack(floor_center)) add_tile(map, 8, 0, unpack(floor_center))
add_tile(map, 9, 0, unpack(wall_bottomleft))
elseif direction == LEFT then elseif direction == LEFT then
add_tile(map, 0, 4, unpack(wall_bottomright))
add_tile(map, 0, 5, unpack(floor_center)) add_tile(map, 0, 5, unpack(floor_center))
add_tile(map, 0, 6, unpack(floor_center)) add_tile(map, 0, 6, unpack(floor_center))
add_tile(map, 0, 7, unpack(wall_topright))
elseif direction == RIGHT then elseif direction == RIGHT then
add_tile(map, 15, 4, unpack(wall_bottomleft))
add_tile(map, 15, 5, unpack(floor_center)) add_tile(map, 15, 5, unpack(floor_center))
add_tile(map, 15, 6, unpack(floor_center)) add_tile(map, 15, 6, unpack(floor_center))
add_tile(map, 15, 7, unpack(wall_topleft))
elseif direction == DOWN then elseif direction == DOWN then
add_tile(map, 6, 11, unpack(wall_topright))
add_tile(map, 7, 11, unpack(floor_center)) add_tile(map, 7, 11, unpack(floor_center))
add_tile(map, 8, 11, unpack(floor_center)) add_tile(map, 8, 11, unpack(floor_center))
add_tile(map, 9, 11, unpack(wall_topleft))
end end
end end

View File

@ -145,7 +145,8 @@ Map* map_lua_generator_run(SDL_Renderer *renderer)
result = lua_pcall(L, 0, LUA_MULTRET, 0); result = lua_pcall(L, 0, LUA_MULTRET, 0);
if (result) { if (result) {
fprintf(stderr, "[!!] Failed to run script: %s\n", lua_tostring(L, -1)); fprintf(stderr, "[!!] Failed to run script: %s\n",
lua_tostring(L, -1));
exit(-1); exit(-1);
} }