Commit 1607de18 authored by Stuart John Watson's avatar Stuart John Watson

No changes, git didn't add all the files when asked nicly...

parent 55498a7e
......@@ -14,6 +14,7 @@ add_executable(IdleCrawler
src/dungeon/dungeon.cpp
src/dungeon/rectangle.cpp
src/dungeon/space.cpp
src/dungeon/dungeonGenerator.cpp
src/dungeon/loader.cpp
src/entity/entity.cpp
src/entity/vision/vision.cpp
......
......@@ -2,8 +2,9 @@
#include "types.h"
#include <string>
#include <iostream>
#include <tuple>
std::tuple<int,int> DungeonGenerator::upStairPosition(){
std::tuple<int,int> Dungeon::upStairPosition(){
int x,y;
for (x=0;x<width;x++){
for (y=0;y<height;y++){
......@@ -12,10 +13,11 @@ std::tuple<int,int> DungeonGenerator::upStairPosition(){
}
}
}
std::cerr << "Warning: No upstairs found";
return std::make_tuple(-1,-1);
}
std::tuple<int,int> DungeonGenerator::downStairPosition(){
std::tuple<int,int> Dungeon::downStairPosition(){
int x,y;
for(x = 0; x < width; x++){
for(y = 0; y < height; y++){
......@@ -24,5 +26,6 @@ std::tuple<int,int> DungeonGenerator::downStairPosition(){
}
}
}
std::cerr << "Warning: No downstairs found";
return std::make_tuple(-1,-1);
}
......@@ -30,6 +30,8 @@ DungeonGenerator::DungeonGenerator(int _width,int _height,int seed) : Dungeon(_w
void DungeonGenerator::populate(){
Space::populate();
std::cerr << "cdp";
//Chance we put a room instead of a corridor down
std::uniform_real_distribution<float> roomChance(0.0,1.0);
......
......@@ -36,7 +36,7 @@ public:
using Space::Space;
std::tuple<int,int> upStairPosition();
std::tuple<int,int> downStairPosition();
}
};
class DungeonGenerator : public Dungeon {
public:
......
......@@ -5,6 +5,7 @@
#include "hero.h"
BasicSolverHero::BasicSolverHero(Dungeon &_dungeon,int _x,int _y,int _viewDistance) : Hero(_dungeon,_x,_y,_viewDistance){
std::cerr << &_dungeon << std::endl;
std::stack<std::tuple<int,int>> trail;
findSolution();
}
......@@ -25,6 +26,8 @@ void BasicSolverHero::findSolution(){
int doY = std::get<1>(pos);
int doN = tiles[doX*height+doY]+1;
std::cerr << doX << "," << doY << "," << doN << std::endl;
if(dungeon.getTile(doX,doY) == STAIRS_DOWN){
trail.push(std::make_tuple(doX,doY));
break;
......
......@@ -48,14 +48,21 @@ void Game::loop(){
// Print Level Seed
std::cout << "Drawing seed for level " << dungeonLevel << ": " << milliseconds_since_epoch << std::endl;
//levels.emplace_back( Dungeon(200,200,milliseconds_since_epoch) );
levels.emplace_back( Loader(202,202,"../testLevels/maze.lvl"));
std::shared_ptr<DungeonGenerator> d(new DungeonGenerator(200,200,milliseconds_since_epoch));
//std::shared_ptr<Loader> d(new Loader(202,202,"../testLevels/maze.lvl"));
levels.emplace_back(d);
// Populate the dungeon with rooms and corridors
levels.back().populate();
d->populate();
// Create hero at coordinates of the dungeon start
std::tuple<int,int> heroStart = levels.back().upStairPosition();
BasicSolverHero levelHero = BasicSolverHero(levels.back(),std::get<0>(heroStart), std::get<1>(heroStart),256 /*vision*/);
std::tuple<int,int> heroStart = levels.back()->upStairPosition();
std::cerr << std::get<0>(heroStart) << ","<< std::get<0>(heroStart) << std::endl;
BasicSolverHero levelHero = BasicSolverHero( *levels.back() ,std::get<0>(heroStart), std::get<1>(heroStart),256 /*vision*/);
//Hero levelHero = Hero(levels.back(),std::get<0>(heroStart), std::get<1>(heroStart),20 /*vision*/);
theHero = &levelHero;
......@@ -65,23 +72,23 @@ void Game::loop(){
generator.seed(milliseconds_since_epoch);
for(int n = 0; n < 0; n++){
// Generate random coordinates for the starting point for each mob
std::uniform_int_distribution<int> x_dist(0, levels.back().getWidth() );
std::uniform_int_distribution<int> y_dist(0, levels.back().getHeight() );
std::uniform_int_distribution<int> x_dist(0, levels.back()->getWidth() );
std::uniform_int_distribution<int> y_dist(0, levels.back()->getHeight() );
int mobx = x_dist(generator);
int moby = y_dist(generator);
while(levels.back().getTile(mobx,moby) != FLOOR ){
while(levels.back()->getTile(mobx,moby) != FLOOR ){
mobx = x_dist(generator);
moby = y_dist(generator);
}
std::shared_ptr<RandomMove> r(new RandomMove( levels.back(), mobx, moby, 0 /*vision*/, milliseconds_since_epoch+n));
std::shared_ptr<RandomMove> r(new RandomMove( *levels.back() , mobx, moby, 0 /*vision*/, milliseconds_since_epoch+n));
entities.emplace_back( r );
}
#endif
int scale = wa.width/levels.back().getWidth();
if (wa.height/levels.back().getHeight() < scale){
scale = wa.height/levels.back().getHeight();
int scale = wa.width/levels.back()->getWidth();
if (wa.height/levels.back()->getHeight() < scale){
scale = wa.height/levels.back()->getHeight();
}
......
......@@ -21,7 +21,7 @@ class Game {
protected:
int const rootWindow;
std::vector<Loader> levels;
std::vector<std::shared_ptr<Dungeon>> levels;
std::vector<std::shared_ptr<Entity>> entities;
Hero *theHero;
......
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