Prevent exit from spawning under collidable.

Removed "accidental" monster player hits
This commit is contained in:
Linus_Probert 2018-02-05 16:15:45 +01:00
parent 27843ab05e
commit 73e300e343
4 changed files with 43 additions and 11 deletions

View File

@ -24,10 +24,12 @@ x XP
x Level threshholds
x Statistics
x More stuff to count
- Particle engine for blood splatter (keep it light!!!)
x Particle engine for blood splatter (keep it light!!!)
- Prevent level exit from spawning on occupied spot
- Menus
- Player death (graphic or text?)
- Make things less difficult and more interesting
- Interesting items
- A different license perhaps?
Legend: ( '-' = future) ( 'x' = completed ) ( 'o' = begun )

View File

@ -120,10 +120,15 @@ local function repack(data)
}
end
local function check_add_decoration(map, x, y, data)
if tile_occupied(map, x, y) then return end
add_decoration(map, x, y, repack(data))
end
local function add_random_decor_to_room()
local decor_count = random(4) - 1
for i=1,decor_count do
add_decoration(map, random(11)+1, random(8)+1, repack(floorDecor[random(#floorDecor)]))
check_add_decoration(map, random(11)+1, random(8)+1, floorDecor[random(#floorDecor)])
end
end
@ -177,16 +182,16 @@ local function add_walls_to_room (map)
end
if random(2) == 1 then
add_decoration(map, 4, 3, repack(lightDecor.candle2))
check_add_decoration(map, 4, 3, lightDecor.candle2)
end
if random(2) == 1 then
add_decoration(map, 11, 3, repack(lightDecor.candle2))
check_add_decoration(map, 11, 3, lightDecor.candle2)
end
if random(2) == 1 then
add_decoration(map, 4, 9, repack(lightDecor.candle2))
check_add_decoration(map, 4, 9, lightDecor.candle2)
end
if random(2) == 1 then
add_decoration(map, 11, 9, repack(lightDecor.candle2))
check_add_decoration(map, 11, 9, lightDecor.candle2)
end
end
@ -230,10 +235,10 @@ local function build_vert_center_coridoor(map, offset)
add_tile(map, 9, offset+j, repack(wall.vertical));
end
if random(2) == 1 then
add_decoration(map, 6, offset + 2, repack(lightDecor.candle1))
check_add_decoration(map, 6, offset + 2, lightDecor.candle1)
end
if random(2) == 1 then
add_decoration(map, 9, offset + 2, repack(lightDecor.candle1))
check_add_decoration(map, 9, offset + 2, lightDecor.candle1)
end
end
@ -245,10 +250,10 @@ local function build_horiz_center_coridoor(map, offset)
add_tile(map, offset+i, 7, repack(wall.horizontal));
end
if random(2) == 1 then
add_decoration(map, offset+3, 4, repack(lightDecor.candle1))
check_add_decoration(map, offset+3, 4, lightDecor.candle1)
end
if random(2) == 1 then
add_decoration(map, offset+3, 7, repack(lightDecor.candle1))
check_add_decoration(map, offset+3, 7, lightDecor.candle1)
end
end

View File

@ -148,6 +148,28 @@ extract_tile_data(lua_State *L,
f_add_tile(map, &tilePos, tile);
}
static
int l_tile_occupied(lua_State *L)
{
Map *map;
Room *room;
MapTile *tile;
Position *rPos;
int x, y;
map = luaL_checkmap(L, 1);
x = (int) luaL_checkinteger(L, 2);
y = (int) luaL_checkinteger(L, 3);
rPos = &map->currentRoom;
room = map->rooms[rPos->x][rPos->y];
tile = room->tiles[x][y];
lua_pushboolean(L, tile->collider || tile->levelExit);
return 1;
}
static
int l_add_tile(lua_State *L)
{
@ -264,6 +286,9 @@ Map* map_lua_generator_run(unsigned int level, SDL_Renderer *renderer)
lua_pushcfunction(L, l_add_monster);
lua_setglobal(L, "add_monster");
lua_pushcfunction(L, l_tile_occupied);
lua_setglobal(L, "tile_occupied");
lua_pushinteger(L, level);
lua_setglobal(L, "CURRENT_LEVEL");

View File

@ -68,7 +68,7 @@ has_collided(Monster *monster, RoomMatrix *matrix)
Position roomPos = position_to_matrix_coords(&monster->sprite->pos);
RoomSpace *space = &matrix->spaces[roomPos.x][roomPos.y];
if (space->player) {
if (space->player && monster->state.current == AGRESSIVE) {
unsigned int dmg = stats_fight(&monster->stats,
&space->player->stats);