Skip to content
Snippets Groups Projects
Commit d2cd17b5 authored by Ian Prins's avatar Ian Prins
Browse files

add param to Room.contains() for border around room

parent 423f42a3
No related branches found
No related tags found
No related merge requests found
......@@ -21,7 +21,7 @@ class Room {
bool exists();
bool touches(Coord);
void printInfo(int);
bool contains(Coord&);
bool contains(Coord&, int border=0);
private:
Coord topLeft;
Coord bottomRight;
......
......@@ -77,7 +77,7 @@ void Room::dig(Level& level) {
}
}
bool Room::contains(Coord& coord) {
return (topLeft[0] <= coord[0]) && (coord[0] <= bottomRight[0])
&& (topLeft[1] <= coord[1]) && (coord[1] <= bottomRight[1]);
bool Room::contains(Coord& coord, int border) {
return (topLeft[0]-border <= coord[0]) && (coord[0] <= bottomRight[0]+border)
&& (topLeft[1]-border <= coord[1]) && (coord[1] <= bottomRight[1]+border);
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment