static bool placeRect(Room rect, room_id tile_) { if (rect.x < 1 || rect.y < 1 || rect.x + rect.w > width() - 1 || rect.y + rect.h > height() - 1) { return(false); } for (int y = rect.y; y < rect.y + rect.h; ++y) { for (int x = rect.x; x < rect.x + rect.w; ++x) { if (getTile(x, y) != room_id.outside_wall) { return(false); } } } for (int y = rect.y - 1; y < rect.y + rect.h + 1; ++y) { for (int x = rect.x - 1; x < rect.x + rect.w + 1; ++x) { if (x == rect.x - 1 || y == rect.y - 1 || x == rect.x + rect.w || y == rect.y + rect.h) { setTile(x, y, room_id.inside_wall); } else { setTile(x, y, tile_); } } } return(true); }
private static void setTile(int x, int y, room_id c) { buf[x, y] = c; }