Commit ca78cbc7 authored by Robert Scott James's avatar Robert Scott James

Tilesets are no longer hardcoded into the program

 Changes to be committed:
	modified:   config.cfg
	modified:   src/dungeon/dungeonGenerator.cpp
	modified:   src/dungeon/space.h
	modified:   src/game/game.cpp
parent 570bc27f
#
# Generator Configuration
# Generator Configuration
#
# Note: All room sizes include the exterior walls!!
version = "1.0";
tileset = "SimpleTiles.png";
generator: {
pRoom = 0.5;
nPlacetries = 500;
......@@ -27,4 +29,4 @@ generator: {
minSize = 7;
maxSize = 40;
}
};
\ No newline at end of file
};
......@@ -11,6 +11,7 @@ libconfig::Config cfg;
int _ = loadConfig(std::string("config.cfg"),&cfg);
const std::string VERSION = fromConfig(&cfg,"version",std::string(""));
const std::string Space::TILESET = fromConfig(&cfg,"tileset",std::string(""));
const float DungeonGenerator::ROOM_CHANCE = fromConfig(&cfg,"generator.pRoom",0.5f);
const int DungeonGenerator::CORRI_MIN_LENGTH = fromConfig(&cfg,"generator.corridor.minLength",10);
......
......@@ -24,7 +24,7 @@ public:
int insertSpace(Space,int,int,LOCATION);
void printDebug();
void draw(Display*&,Window&,GC&,int);
const static std::string TILESET;
protected:
int width;
int height;
......
......@@ -61,12 +61,19 @@ void Game::loop(){
std::shared_ptr<Loader> d(new Loader(202,202,levelToLoad));
levels.emplace_back(d);
d->populate();
// Read the tiles from file
int notUsingTiles = readTiles(d->TILESET,dpy,w,gc);
} else {
std::shared_ptr<DungeonGenerator> d(new DungeonGenerator(200,200,milliseconds_since_epoch));
levels.emplace_back(d);
d->populate();
// Read the tiles from file
int notUsingTiles = readTiles(d->TILESET,dpy,w,gc);
}
// Create hero at coordinates of the dungeon start
std::tuple<int,int> heroStart = levels.back()->upStairPosition();
......@@ -126,7 +133,7 @@ void Game::loop(){
}
XCopyArea(dpy, double_buffer, w, gc, 0, 0, wa.width, wa.height, 0, 0);
XFillRectangle(dpy, double_buffer, gc, 0, 0, wa.width, wa.height);
XFillRectangle(dpy, double_buffer, gc, 0, 0, wa.width, wa.height);
XFlush(dpy);
if(theHero->levelComplete() == true){
break;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment