forked from NotAShelf/rogged
map: add is_floor() helper to check walkable tiles
Signed-off-by: NotAShelf <raf@notashelf.dev> Change-Id: I7368f74d1cbcf5913e5d8e9331cfa4326a6a6964
This commit is contained in:
parent
c61e31f628
commit
d3798cc99f
2 changed files with 5 additions and 5 deletions
|
|
@ -13,7 +13,7 @@ void map_init(Map *map) {
|
|||
map->room_count = 0;
|
||||
}
|
||||
|
||||
int is_floor(Map *map, int x, int y) {
|
||||
int is_floor(const Map *map, int x, int y) {
|
||||
if (!in_bounds(x, y, MAP_WIDTH, MAP_HEIGHT))
|
||||
return 0;
|
||||
return map->tiles[y][x] == TILE_FLOOR || map->tiles[y][x] == TILE_STAIRS;
|
||||
|
|
@ -62,8 +62,8 @@ static int room_overlaps(Room *rooms, int count, Room *new_room) {
|
|||
// Add padding to prevent rooms from touching
|
||||
for (int i = 0; i < count; i++) {
|
||||
Room *r = &rooms[i];
|
||||
if (!(new_room->x > r->x + r->w || new_room->x + new_room->w < r->x ||
|
||||
new_room->y > r->y + r->h || new_room->y + new_room->h < r->y)) {
|
||||
if (!(new_room->x > r->x + r->w || new_room->x + new_room->w < r->x || new_room->y > r->y + r->h ||
|
||||
new_room->y + new_room->h < r->y)) {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
#include "common.h"
|
||||
|
||||
// Check if a tile is walkable floor
|
||||
int is_floor(Map *map, int x, int y);
|
||||
int is_floor(const Map *map, int x, int y);
|
||||
|
||||
// Get room center coordinates
|
||||
void get_room_center(Room *room, int *cx, int *cy);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue