Fixes some render layer issues

- Chance for more daggers in containers
- Less health from meat
- Prevent exit from spawning under containers
This commit is contained in:
Linus Probert 2018-08-11 15:15:53 +02:00
parent 4ba301769a
commit b4a6c4b46f
10 changed files with 54 additions and 25 deletions

View File

@ -398,17 +398,22 @@ local function build_coridoor_room(room)
build_center_corner_walls(room, exits)
end
local function room_tile_available(room, rx, ry)
return not room.chests[rx][ry]
and not room.traps[rx][ry]
and not room.monsters[rx][ry]
and not room.decor[rx][ry]
and (room.tiles[rx][ry]
and not room.tiles[rx][ry][5]
and not room.tiles[rx][ry][8])
end
local function add_level_exit(room)
success = false
while not success do
x = random(14)
y = random(10)
if not room.decor[x][y]
and not room.traps[x][y]
and (room.tiles[x][y]
and not room.tiles[x][y][5]
and not room.tiles[x][y][8])
then
if room_tile_available(room, x, y) then
success = true
room.tiles[x][y] = special.level_exit
end
@ -453,13 +458,7 @@ function module.add_full_lighting(room)
end
function module.is_tile_avilable(room, rx, ry)
return not room.chests[rx][ry]
and not room.traps[rx][ry]
and not room.monsters[rx][ry]
and not room.decor[rx][ry]
and (room.tiles[rx][ry]
and not room.tiles[rx][ry][5]
and not room.tiles[rx][ry][8])
return room_tile_available(room, rx, ry);
end
function module.create_empty_room()

View File

@ -56,6 +56,8 @@ item_collected(Item *item, Player *player)
gui_log("You open a container");
item->opened = true;
item->sprite->texture_index = 1;
if (!item->items)
gui_log("You find nothing inside");
}
if (item->effect != NULL)

View File

@ -48,7 +48,7 @@ static void
eat_flesh(Item *item, Player *player)
{
int original_hp = player->stats.hp;
player->stats.hp += (int) item->value * player->stats.lvl;
player->stats.hp += (int) item->value;
if (player->stats.hp > player->stats.maxhp)
player->stats.hp = player->stats.maxhp;

View File

@ -538,13 +538,15 @@ run_game_render(void)
SDL_RenderSetViewport(gRenderer, &gameViewport);
map_render(gMap, gCamera);
particle_engine_render_game(gCamera);
map_render_top_layer(gMap, gCamera);
map_render_mid_layer(gMap, gCamera);
if (!is_player_dead()) {
player_render(gPlayer, gCamera);
player_render_toplayer(gPlayer, gCamera);
}
map_render_top_layer(gMap, gCamera);
if (gPlayer->class == MAGE || gPlayer->class == PALADIN)
roommatrix_render_mouse_square(gRoomMatrix, gCamera);

View File

@ -309,15 +309,8 @@ void map_render(Map *map, Camera *cam)
}
void
map_render_top_layer(Map *map, Camera *cam)
map_render_mid_layer(Map *map, Camera *cam)
{
LinkedList *monsterItem = map->monsters;
while (monsterItem != NULL) {
Monster *monster = monsterItem->data;
monsterItem = monsterItem->next;
monster_render(monster, cam);
}
LinkedList *items = map->items;
while (items != NULL) {
item_render(items->data, cam);
@ -329,6 +322,24 @@ map_render_top_layer(Map *map, Camera *cam)
artifact_render(artifacts->data, cam);
artifacts = artifacts->next;
}
LinkedList *monsterItem = map->monsters;
while (monsterItem != NULL) {
Monster *monster = monsterItem->data;
monsterItem = monsterItem->next;
monster_render(monster, cam);
}
}
void
map_render_top_layer(Map *map, Camera *cam)
{
LinkedList *monsterItem = map->monsters;
while (monsterItem != NULL) {
Monster *monster = monsterItem->data;
monsterItem = monsterItem->next;
monster_render_top_layer(monster, cam);
}
}
void map_set_current_room(Map *map, Position *pos)

View File

@ -103,6 +103,9 @@ map_update(UpdateData*);
void
map_render(Map*, Camera*);
void
map_render_mid_layer(Map*, Camera*);
void
map_render_top_layer(Map*, Camera*);

View File

@ -336,8 +336,11 @@ l_add_chest(lua_State *L)
linkedlist_append(&chest->items, item_builder_build_item(TREASURE, level));
if (get_random(4) == 0)
linkedlist_append(&chest->items, item_builder_build_item(HEALTH, level));
if (get_random(4) == 0)
linkedlist_append(&chest->items, item_builder_build_item(DAGGER, level));
if (get_random(4) == 0) {
Item *dagger = item_builder_build_item(DAGGER, level);
dagger->value = get_random(4) + 1;
linkedlist_append(&chest->items, dagger);
}
linkedlist_append(&map->items, chest);

View File

@ -571,6 +571,11 @@ monster_render(Monster *m, Camera *cam)
return;
sprite_render(m->sprite, cam);
}
void
monster_render_top_layer(Monster *m, Camera *cam)
{
if (m->stateIndicator.displayCount != 0)
sprite_render(m->stateIndicator.sprite, cam);
}

View File

@ -82,6 +82,9 @@ monster_move(Monster*, RoomMatrix*);
void
monster_render(Monster*, Camera*);
void
monster_render_top_layer(Monster*, Camera*);
void
monster_hit(Monster*, unsigned int dmg);

View File

@ -17,6 +17,7 @@
*/
#include <stdlib.h>
#include <string.h>
#include "projectile.h"
#include "util.h"
#include "texturecache.h"