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

add dig function to rooms

parent e75ba8e1
No related branches found
No related tags found
No related merge requests found
......@@ -5,9 +5,9 @@ class Room {
public:
Room(Coord, Coord);
Coord operator[](int);
void dig(Level&);
Coord getPosition1();
Coord getPosition2();
void dig(Level);
private:
Coord topLeft;
Coord bottomRight;
......
#include "include/room.h"
#include "include/coord.h"
#include "include/tiles.h"
#include <stdexcept>
#include <string>
......@@ -16,3 +17,12 @@ Coord Room::operator[](int corner) {
}
throw std::invalid_argument("param must be 0 or 1, not " + std::to_string(corner));
}
void Room::dig(Level& level) {
for (auto x=topLeft[0]; x <= bottomRight[0]; x++) {
for (auto y=topLeft[1]; y <= bottomRight[1]; y++) {
level[Coord(x, y)] = Floor();
}
}
}
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