Skip to content
Snippets Groups Projects
Commit 298730ea authored by Ian Prins's avatar Ian Prins
Browse files
parents 60051508 99ce6adb
No related branches found
No related tags found
No related merge requests found
......@@ -16,5 +16,8 @@
# CLion stuff (ignore)
.idea/*
# Score record file
scores.txt
# Library files
src/*.so
\ No newline at end of file
src/*.so
......@@ -12,3 +12,5 @@ char Feature::getSymbol() {
Coord Feature::getLocation() {
return this->location;
}
Feature::~Feature() {}
......@@ -7,6 +7,7 @@ class Feature {
Feature(char, Coord);
char getSymbol();
Coord getLocation();
virtual ~Feature();
private:
Coord location;
char symbol;
......
......@@ -10,6 +10,7 @@
#include "goldpile.h"
#include "room.h"
#include "tunnel.h"
#include "feature.h"
class Room;
......@@ -48,6 +49,8 @@ class Level {
std::vector<Room>& getRooms();
std::vector<Feature*>& getFeatures();
private:
// Store mobs with a notation for how many
......@@ -59,9 +62,9 @@ class Level {
Mob* mob;
int delay;
};
const Coord nearby[8] = { Coord(-1,-1), Coord(0,-1), Coord(1,-1), Coord(1,0), Coord(1,1), Coord(0,1), Coord(-1,1), Coord(-1,0) };
const int MAX_ROOMS = 9;
#define MAX_ROOMS_DEF (9)
static const int MAX_ROOMS = 9;
const double GOLD_CHANCE = .333;
const double ROOM_EXIST_CHANCE = 0.9;
static const int ROOM_PADDING = 2;
......@@ -72,6 +75,7 @@ class Level {
std::vector<ClockItem> mobs;
std::vector<GoldPile> golds;
std::vector<Tunnel> tunnels;
std::vector<Feature*> features;
int genGoldAmount(Generator);
void addTunnel(int, int, bool*, bool*, Generator);
Coord size;
......
......@@ -14,6 +14,7 @@
#include "include/tunnel.h"
#include "include/terrain.h"
#include "include/mob.h"
#include "include/feature.h"
Level::Level(int depth)
: size(getSize())
......@@ -27,6 +28,10 @@ Level::Level(int depth)
}
}
std::vector<Feature*>& Level::getFeatures() {
return features;
}
int Level::getDepth() {
return depth;
}
......@@ -152,7 +157,7 @@ void Level::generate(PlayerChar player) {
}
//Used to say: If A -> B, then B -> A
bool symmetric [MAX_ROOMS][MAX_ROOMS] = {{0}};//Take care of non-existent rooms
bool symmetric [MAX_ROOMS_DEF][MAX_ROOMS_DEF] = {};//Take care of non-existent rooms
for (auto i=0; i < MAX_ROOMS; i++){
......
......@@ -13,7 +13,7 @@ MasterController::MasterController()
void MasterController::run() {
const int spacer = 5;
std::cout << "Welcome to Rogue Reborn!" << std::endl;
TCODConsole::setCustomFont("assets/terminal .png");
TCODConsole::setCustomFont("assets/terminal.png");
//Init console
Coord lSize = Level::getSize();
TCODConsole::initRoot(lSize[0], lSize[1] + spacer, "Rogue Reborn", false);
......
......@@ -4,6 +4,10 @@
#include "include/level.h"
#include "include/ripscreen.h"
#include "include/invscreen.h"
#include "include/stairs.h"
#include "include/feature.h"
#include "include/item.h"
#include "include/goldpile.h"
#include "libtcod/include/libtcod.hpp"
#include <iostream>
#include <string>
......@@ -119,6 +123,11 @@ void PlayState::draw(TCODConsole* con) {
} else if (player->getLog().size() > 0) {
con->print(0, 0, player->getLog().back().c_str());
}
// Display the features
for (Feature* feat : level->getFeatures()) {
auto scrPos = feat->getLocation().asScreen();
con->putChar(scrPos[0], scrPos[1], feat->getSymbol());
}
// Display the mobs
for (Mob* mob : level->getMobs()) {
auto scrPos = mob->getLocation().asScreen();
......@@ -178,6 +187,26 @@ UIState* PlayState::handleInput(TCOD_key_t key) {
if (newPos != player->getLocation() && level->contains(newPos) && (*level)[newPos].isPassable()) {
player->setLocation(newPos);
currRoom = updateMap();
for (Feature*& feat : level->getFeatures()) {
if (feat->getLocation() != newPos) {
continue;
}
Item* i = dynamic_cast<Item*>(feat);
if (i != NULL) {
player->pickupItem(i);
continue;
}
GoldPile* gp = dynamic_cast<GoldPile*>(feat);
if (gp != NULL) {
player->collectGold(gp);
feat = NULL;
continue;
}
Stairs* st = dynamic_cast<Stairs*>(feat);
if (st != NULL) {
std::cout << "transition level\n";
}
}
}
level->pushMob(player, 50);
return this;
......
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