Fixes compile error and some graphical issues

- Keys and artifacts should render on to of other items
- Locked doors will impact surrounding wall layouts
This commit is contained in:
Linus Probert 2019-03-20 19:56:30 +01:00
parent 2ae6ada297
commit ebfe2715e0
5 changed files with 39 additions and 17 deletions

View File

@ -325,17 +325,19 @@ function createJumbleLayout(matrix)
end end
function draw_layout_to_room(room, matrix, roomx, roomy) function draw_layout_to_room(room, matrix, roomx, roomy)
local wallTypes = {"#", "\"", "/", "d", "g", "S", "G"}
for i=2,13 do for i=2,13 do
for j=2,10 do for j=2,10 do
if matrix[i][j] == "p" then if matrix[i][j] == "p" then
setPitTile(room, matrix, i, j); setPitTile(room, matrix, i, j);
elseif matrix[i][j] == "#" then elseif matrix[i][j] == "#" then
setBlockTile(room, matrix, i, j, walls, {"#", "\"", "/", "d", "g"}, false) setBlockTile(room, matrix, i, j, walls, wallTypes, false)
elseif matrix[i][j] == "\"" then elseif matrix[i][j] == "\"" then
setBlockTile(room, matrix, i, j, walls, {"#", "\"", "/", "d", "g"}, false) setBlockTile(room, matrix, i, j, walls, wallTypes, false)
room.decor[i][j] = lights.candle1 room.decor[i][j] = lights.candle1
elseif matrix[i][j] == "/" then elseif matrix[i][j] == "/" then
setBlockTile(room, matrix, i, j, walls, {"#", "\"", "/", "d", "g"}, false) setBlockTile(room, matrix, i, j, walls, wallTypes, false)
if random(2) == 1 then if random(2) == 1 then
room.decor[i][j] = lights.candle1 room.decor[i][j] = lights.candle1
else else

25
src/doorlocktype.h Normal file
View File

@ -0,0 +1,25 @@
/*
* BreakHack - A dungeone crawler RPG
* Copyright (C) 2018 Linus Probert <linus.probert@gmail.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
typedef enum DoorLockType {
LOCK_NONE,
LOCK_SILVER,
LOCK_GOLD
} DoorLockType;

View File

@ -32,16 +32,11 @@
#include "player.h" #include "player.h"
#include "map_room_modifiers.h" #include "map_room_modifiers.h"
#include "object.h" #include "object.h"
#include "doorlocktype.h"
typedef struct UpdateData UpdateData; typedef struct UpdateData UpdateData;
typedef struct Trap Trap; typedef struct Trap Trap;
typedef enum DoorLockType {
LOCK_NONE,
LOCK_SILVER,
LOCK_GOLD
} DoorLockType;
typedef struct MapTile_t { typedef struct MapTile_t {
Sprite *sprite; Sprite *sprite;
bool collider; bool collider;

View File

@ -690,25 +690,25 @@ monster_drop_loot(Monster *monster, Map *map, Player *player)
linkedlist_append(&map->artifacts, a); linkedlist_append(&map->artifacts, a);
Item *treasure = item_builder_build_item(TREASURE, map->level*2); Item *treasure = item_builder_build_item(TREASURE, map->level*2);
treasure->sprite->pos = monsterTilePos; treasure->sprite->pos = monsterTilePos;
linkedlist_push(&map->items, treasure); linkedlist_append(&map->items, treasure);
} }
if (monster->items.keyType != LOCK_NONE) { if (monster->items.keyType != LOCK_NONE) {
Item *key = item_builder_build_key(monster->items.keyType); Item *key = item_builder_build_key(monster->items.keyType);
key->sprite->pos = monsterTilePos; key->sprite->pos = monsterTilePos;
linkedlist_push(&map->items, key); linkedlist_append(&map->items, key);
} }
if (strcmp(monster->label, "The Trader") == 0) { if (strcmp(monster->label, "The Trader") == 0) {
Item *treasure = item_builder_build_treasure(PLATINUM, 10 * monster->stats.lvl); Item *treasure = item_builder_build_treasure(PLATINUM, 10 * monster->stats.lvl);
treasure->sprite->pos = monsterTilePos; treasure->sprite->pos = monsterTilePos;
linkedlist_push(&map->items, treasure); linkedlist_append(&map->items, treasure);
} }
if (strcmp(monster->label, "A Fairy") == 0) { if (strcmp(monster->label, "A Fairy") == 0) {
Item *treasure = item_builder_build_treasure(PLATINUM, 3 * monster->stats.lvl); Item *treasure = item_builder_build_treasure(PLATINUM, 3 * monster->stats.lvl);
treasure->sprite->pos = monsterTilePos; treasure->sprite->pos = monsterTilePos;
linkedlist_push(&map->items, treasure); linkedlist_append(&map->items, treasure);
} }
if (monster->stats.lvl > 2 && get_random(29) == 0) { if (monster->stats.lvl > 2 && get_random(29) == 0) {
@ -744,15 +744,15 @@ monster_drop_loot(Monster *monster, Map *map, Player *player)
gui_log("%s dropped something", monster->label); gui_log("%s dropped something", monster->label);
if (item_count == 1) { if (item_count == 1) {
linkedlist_append(&map->items, items[0]); linkedlist_push(&map->items, items[0]);
} else { } else {
Item *container = item_builder_build_sack(); Item *container = item_builder_build_sack();
container->sprite->pos = monsterTilePos; container->sprite->pos = monsterTilePos;
unsigned int i; unsigned int i;
for (i = 0; i < item_count; ++i) { for (i = 0; i < item_count; ++i) {
linkedlist_append(&container->items, items[i]); linkedlist_push(&container->items, items[i]);
} }
linkedlist_append(&map->items, container); linkedlist_push(&map->items, container);
} }
} }

View File

@ -25,9 +25,9 @@
#include "actiontext.h" #include "actiontext.h"
#include "player.h" #include "player.h"
#include "linkedlist.h" #include "linkedlist.h"
#include "doorlocktype.h"
struct UpdateData; struct UpdateData;
enum DoorLockType;
typedef enum { typedef enum {
PACIFIST, PACIFIST,