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

add flags to determine type of room

parent a54f3697
No related branches found
No related tags found
No related merge requests found
#pragma once
#include <vector>
#include "coord.h"
#include "terrain.h"
#include "random.h"
#include "playerchar.h"
#include "goldpile.h"
#include "room.h"
#ifndef LEVEL_H
#define LEVEL_H
class Room;
class Level {
public:
......@@ -21,11 +23,10 @@ class Level {
const double GOLD_CHANCE = .333;
const Coord SIZE = Coord(80, 25);
std::vector<std::vector<Terrain> > tiles;
std::vector<Room> rooms;
std::vector<Mob> mobs;
std::vector<GoldPile> golds;
int genGoldAmount(Generator);
Coord size;
int depth;
};
#endif
#pragma once
#include "coord.h"
#include "level.h"
class Level;
class Room {
public:
enum Darkness {DARK, LIT};
enum Treasure {TREASURE, WORTHLESS};
enum Hidden {HIDDEN, VISIBLE};
Room(Coord, Coord, Darkness, Treasure, Hidden);
Room(Coord, Coord);
Coord operator[](int);
void dig(Level&);
......@@ -11,4 +19,7 @@ class Room {
private:
Coord topLeft;
Coord bottomRight;
Darkness isDark;
Treasure isTreasure;
Hidden isHidden;
};
......@@ -49,10 +49,13 @@ void Level::generate(PlayerChar player) {
Coord roomPosition, roomSize;
do {
roomSize = Coord(4+gen.intFromRange(0, maxRoomSize[0]-4), 4+gen.intFromRange(0, maxRoomSize[1]-4));
Coord positionRand = Coord(gen.intFromRange(0, maxRoomSize[0] - roomSize[0]), gen.intFromRange(0, maxRoomSize[1] - roomSize[1]));
Coord positionRand = Coord(gen.intFromRange(0, maxRoomSize[0] - roomSize[0]),
gen.intFromRange(0, maxRoomSize[1] - roomSize[1]));
roomPosition = boxTopLeft + positionRand;
} while (roomPosition[1] == 0);
Room curRoom = Room(roomPosition, roomPosition + roomSize);
Room::Darkness isDark = gen.intFromRange(0, 10) < depth - 1 ? Room::DARK : Room::LIT;
Room curRoom = Room(roomPosition, roomPosition + roomSize,
isDark, Room::WORTHLESS, Room::VISIBLE);
curRoom.dig(*this);
//put gold in current room
if (gen() < GOLD_CHANCE && (!player.foundAmulet() || depth >= player.maxDelved())) {
......@@ -61,5 +64,7 @@ void Level::generate(PlayerChar player) {
golds.push_back(GoldPile(goldPos, goldAmount));
}
//put monsters in current room
rooms.push_back(curRoom);
}
}
......@@ -5,9 +5,16 @@
#include <string>
Room::Room(Coord topLeft, Coord bottomRight)
: Room(topLeft, bottomRight, LIT, WORTHLESS, VISIBLE)
{}
Room::Room(Coord topLeft, Coord bottomRight, Darkness dark, Treasure treas, Hidden hid)
: topLeft(topLeft)
, bottomRight(bottomRight)
{}
, isDark(dark)
, isTreasure(treas)
, isHidden(hid)
{}
Coord Room::operator[](int corner) {
if (corner == 0) {
......
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