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

add getter, utility func, change constructor, add constant

parent 58d68d05
No related branches found
No related tags found
No related merge requests found
......@@ -10,13 +10,16 @@
class Level {
public:
Level(Coord, int);
Level(int);
Terrain& tileAt(Coord);
Coord getSize();
Terrain& operator[](Coord);
void generate(PlayerChar);
bool contains(Coord);
private:
const int MAX_ROOMS = 9;
const double GOLD_CHANCE = .333;
const Coord SIZE = Coord(80, 25);
std::vector<std::vector<Terrain> > tiles;
std::vector<Mob> mobs;
std::vector<GoldPile> golds;
......
......@@ -8,8 +8,8 @@
#include "include/random.h"
#include "include/playerchar.h"
Level::Level(Coord size, int depth)
: size(size)
Level::Level(int depth)
: size(SIZE)
, depth(depth)
{
for (auto x=0; x < size[0]; x++) {
......@@ -28,6 +28,14 @@ Terrain& Level::tileAt(Coord coord) {
return tiles[coord[0]][coord[1]];
}
Coord Level::getSize() {
return size;
}
bool Level::contains(Coord pos) {
return pos[0] >= 0 && pos[1] >= 0 && pos[0] < size[0] && pos[1] < size[1];
}
int Level::genGoldAmount(Generator gen) {
return 2 + gen.intFromRange(0, 50 + 10 * depth);
}
......
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