Hopefully fixes the "exit under decor" problem for the last time.
This commit is contained in:
parent
a26c7be122
commit
f9443b1468
|
@ -121,12 +121,17 @@ local function repack(data)
|
||||||
end
|
end
|
||||||
|
|
||||||
local function check_add_decoration(map, x, y, data)
|
local function check_add_decoration(map, x, y, data)
|
||||||
if tile_occupied(map, x, y) then return end
|
if tile_occupied(map, x, y) then
|
||||||
|
return false
|
||||||
|
end
|
||||||
add_decoration(map, x, y, repack(data))
|
add_decoration(map, x, y, repack(data))
|
||||||
|
return true
|
||||||
end
|
end
|
||||||
|
|
||||||
local function check_add_tile(map, x, y, data)
|
local function check_add_tile(map, x, y, data)
|
||||||
if tile_occupied(map, x, y) then return false end
|
if tile_occupied(map, x, y) then
|
||||||
|
return false
|
||||||
|
end
|
||||||
add_tile(map, x, y, repack(data))
|
add_tile(map, x, y, repack(data))
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
@ -232,7 +237,7 @@ local function add_level_exit(map)
|
||||||
while not success do
|
while not success do
|
||||||
x = random(14)
|
x = random(14)
|
||||||
y = random(10)
|
y = random(10)
|
||||||
success = check_add_tile(map, x, y, special.level_exit);
|
success = check_add_tile(map, x, y, special.level_exit)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -24,7 +24,6 @@ typedef struct MapTile_t {
|
||||||
|
|
||||||
typedef struct Room_t {
|
typedef struct Room_t {
|
||||||
MapTile* tiles[MAP_ROOM_WIDTH][MAP_ROOM_HEIGHT];
|
MapTile* tiles[MAP_ROOM_WIDTH][MAP_ROOM_HEIGHT];
|
||||||
MapTile* secondary_tiles[MAP_ROOM_WIDTH][MAP_ROOM_HEIGHT];
|
|
||||||
MapTile* decorations[MAP_ROOM_WIDTH][MAP_ROOM_HEIGHT];
|
MapTile* decorations[MAP_ROOM_WIDTH][MAP_ROOM_HEIGHT];
|
||||||
} Room;
|
} Room;
|
||||||
|
|
||||||
|
|
|
@ -153,10 +153,13 @@ int l_tile_occupied(lua_State *L)
|
||||||
{
|
{
|
||||||
Map *map;
|
Map *map;
|
||||||
Room *room;
|
Room *room;
|
||||||
MapTile *tile;
|
MapTile *tile, *decor;
|
||||||
Position *rPos;
|
Position *rPos;
|
||||||
int x, y;
|
int x, y;
|
||||||
|
bool response = false;
|
||||||
|
|
||||||
|
tile = NULL;
|
||||||
|
decor = NULL;
|
||||||
|
|
||||||
map = luaL_checkmap(L, 1);
|
map = luaL_checkmap(L, 1);
|
||||||
x = (int) luaL_checkinteger(L, 2);
|
x = (int) luaL_checkinteger(L, 2);
|
||||||
|
@ -164,9 +167,14 @@ int l_tile_occupied(lua_State *L)
|
||||||
|
|
||||||
rPos = &map->currentRoom;
|
rPos = &map->currentRoom;
|
||||||
room = map->rooms[rPos->x][rPos->y];
|
room = map->rooms[rPos->x][rPos->y];
|
||||||
tile = room->tiles[x][y];
|
|
||||||
|
|
||||||
lua_pushboolean(L, tile->collider || tile->levelExit);
|
tile = room->tiles[x][y];
|
||||||
|
decor = room->decorations[x][y];
|
||||||
|
|
||||||
|
response = response || (tile && (tile->collider || tile->levelExit));
|
||||||
|
response = response || (decor && (decor->collider || decor->levelExit));
|
||||||
|
|
||||||
|
lua_pushboolean(L, response);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue