Prevent tiles with objects on them from falling.

This commit is contained in:
Linus Probert 2018-10-15 09:35:05 +02:00
parent ee56143d0d
commit fd8799f36b
3 changed files with 10 additions and 2 deletions

View File

@ -293,11 +293,16 @@ move(Player *player, RoomMatrix *matrix, Vector2d direction)
if (!has_collided(player, matrix, direction)) { if (!has_collided(player, matrix, direction)) {
action_spent(player); action_spent(player);
RoomSpace *lastSpace = &matrix->spaces[lastPos.x][lastPos.y];
if (lastPos.x > 1 && if (lastPos.x > 1 &&
lastPos.y > 1 && lastPos.y > 1 &&
lastPos.x < 14 && lastPos.x < 14 &&
lastPos.y < 10) lastPos.y < 10 &&
map_trigger_tile_fall(matrix->spaces[lastPos.x][lastPos.y].tile); lastSpace->decoration == NULL &&
lastSpace->trap == NULL &&
lastSpace->objects == NULL
)
map_trigger_tile_fall(lastSpace->tile);
} }
} }

View File

@ -47,6 +47,7 @@ roommatrix_reset(RoomMatrix *m)
space->player = NULL; space->player = NULL;
space->trap = NULL; space->trap = NULL;
space->tile = NULL; space->tile = NULL;
space->decoration = NULL;
while (space->items != NULL) while (space->items != NULL)
linkedlist_pop(&space->items); linkedlist_pop(&space->items);
while (space->artifacts != NULL) while (space->artifacts != NULL)
@ -126,6 +127,7 @@ void roommatrix_populate_from_map(RoomMatrix *rm, Map *m)
r->tiles[i][j]->lethal; r->tiles[i][j]->lethal;
} }
if (r->decorations[i][j]) { if (r->decorations[i][j]) {
space->decoration = r->decorations[i][j];
space->occupied |= space->occupied |=
r->decorations[i][j]->collider; r->decorations[i][j]->collider;
space->lightsource |= space->lightsource |=

View File

@ -45,6 +45,7 @@ typedef struct RoomSpace {
bool damaging; bool damaging;
int light; int light;
MapTile *tile; MapTile *tile;
MapTile *decoration;
Monster *monster; Monster *monster;
Player *player; Player *player;
Trap *trap; Trap *trap;