From 171f8c8b5e7f8dbf133bb1c70f8e83fe096fbcc4 Mon Sep 17 00:00:00 2001 From: Linus Probert Date: Wed, 6 Dec 2017 17:00:51 +0100 Subject: [PATCH] Nicer exits in rooms --- data/mapgen.lua | 20 ++++++++++---------- data/maproombuilder.lua | 26 ++++++++++++++++++++------ src/map_lua.c | 3 ++- 3 files changed, 32 insertions(+), 17 deletions(-) diff --git a/data/mapgen.lua b/data/mapgen.lua index c7d4d0a..27ba9b2 100644 --- a/data/mapgen.lua +++ b/data/mapgen.lua @@ -89,16 +89,16 @@ load_textures(map) local map_matrix = generate_path() -- Print path [Debug] -for i=1,10 do - for j=1,10 do - if not map_matrix[j][i].goal then - io.write(map_matrix[j][i].path_dir .. " ") - else - io.write("G ") - end - end - io.write("\n") -end +--for i=1,10 do + --for j=1,10 do + --if not map_matrix[j][i].goal then + --io.write(map_matrix[j][i].path_dir .. " ") + --else + --io.write("G ") + --end + --end + --io.write("\n") +--end for i=1,10 do for j=1,10 do diff --git a/data/maproombuilder.lua b/data/maproombuilder.lua index cc17cde..bd2797d 100644 --- a/data/maproombuilder.lua +++ b/data/maproombuilder.lua @@ -1,3 +1,9 @@ +-- CONSTANTS +UP = 1 +LEFT = 2 +RIGHT = 3 +DOWN = 4 + -- Textures local floorTexture = nil local wallTexture = nil @@ -36,12 +42,12 @@ function load_textures(map) floor_bottomleft = { floorTexture, xo + 0, yo + 32, false } floor_bottomright = { floorTexture, xo + 32, yo + 32, false } - wall_topleft = { wallTexture, xo + 0, yo + 0, false } - wall_topright = { wallTexture, xo + 32, yo + 0, false } - wall_bottomleft = { wallTexture, xo + 0, yo + 32, false } - wall_bottomright = { wallTexture, xo + 32, yo + 32, false } - wall_vertical = { wallTexture, xo + 0, yo + 16, false } - wall_horizontal = { wallTexture, xo + 16, yo + 0, false } + wall_topleft = { wallTexture, xo + 0, yo + 0, true } + wall_topright = { wallTexture, xo + 32, yo + 0, true } + wall_bottomleft = { wallTexture, xo + 0, yo + 32, true } + wall_bottomright = { wallTexture, xo + 32, yo + 32, true } + wall_vertical = { wallTexture, xo + 0, yo + 16, true } + wall_horizontal = { wallTexture, xo + 16, yo + 0, true } end function create_room () @@ -105,16 +111,24 @@ function add_exit(map, direction) if direction > 4 then return end if direction == UP then + add_tile(map, 6, 0, unpack(wall_bottomright)) add_tile(map, 7, 0, unpack(floor_center)) add_tile(map, 8, 0, unpack(floor_center)) + add_tile(map, 9, 0, unpack(wall_bottomleft)) elseif direction == LEFT then + add_tile(map, 0, 4, unpack(wall_bottomright)) add_tile(map, 0, 5, unpack(floor_center)) add_tile(map, 0, 6, unpack(floor_center)) + add_tile(map, 0, 7, unpack(wall_topright)) elseif direction == RIGHT then + add_tile(map, 15, 4, unpack(wall_bottomleft)) add_tile(map, 15, 5, unpack(floor_center)) add_tile(map, 15, 6, unpack(floor_center)) + add_tile(map, 15, 7, unpack(wall_topleft)) elseif direction == DOWN then + add_tile(map, 6, 11, unpack(wall_topright)) add_tile(map, 7, 11, unpack(floor_center)) add_tile(map, 8, 11, unpack(floor_center)) + add_tile(map, 9, 11, unpack(wall_topleft)) end end diff --git a/src/map_lua.c b/src/map_lua.c index 4f278fe..b1b6690 100644 --- a/src/map_lua.c +++ b/src/map_lua.c @@ -145,7 +145,8 @@ Map* map_lua_generator_run(SDL_Renderer *renderer) result = lua_pcall(L, 0, LUA_MULTRET, 0); 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); }