2013-04-11 18:44:00 +00:00
|
|
|
/*
|
|
|
|
* Generator.h
|
|
|
|
*
|
|
|
|
* Created on: 07.04.2013
|
|
|
|
* Author: Felix
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef DG_GENERATOR_H_
|
|
|
|
#define DG_GENERATOR_H_
|
|
|
|
|
|
|
|
#include <SFML/Graphics.hpp>
|
|
|
|
|
2013-04-29 14:49:16 +00:00
|
|
|
#include "../sprites/Tile.h"
|
2013-04-28 21:18:17 +00:00
|
|
|
|
2013-04-29 14:49:16 +00:00
|
|
|
class World;
|
2013-04-28 16:11:39 +00:00
|
|
|
class Pathfinder;
|
2013-04-11 18:44:00 +00:00
|
|
|
|
|
|
|
class Generator {
|
|
|
|
public:
|
2013-04-29 14:49:16 +00:00
|
|
|
explicit Generator(World& world, Pathfinder& pathfinder);
|
|
|
|
void generateTiles(const sf::IntRect& area);
|
2013-04-11 18:44:00 +00:00
|
|
|
sf::Vector2f getPlayerSpawn() const;
|
2013-05-08 09:19:21 +00:00
|
|
|
std::vector<sf::Vector2f> getEnemySpawns(const sf::IntRect& area) const;
|
2013-04-11 18:44:00 +00:00
|
|
|
|
2013-05-01 19:32:03 +00:00
|
|
|
private:
|
|
|
|
typedef Tile::Type type;
|
|
|
|
typedef std::map<int, std::map<int, type> > array;
|
|
|
|
|
2013-04-11 18:44:00 +00:00
|
|
|
private:
|
2013-04-28 22:41:00 +00:00
|
|
|
sf::Vector2i findClosestFloor(const sf::Vector2i& position) const;
|
2013-05-01 19:32:03 +00:00
|
|
|
static void fill(array& in, const sf::IntRect& area, type value);
|
|
|
|
static void filterWalls(const array& in, array& out, int x, int y,
|
|
|
|
int longside, int shortside, int subtract);
|
|
|
|
static int countWalls(const array& in, const sf::IntRect& area);
|
|
|
|
void generateAreas(const array& in, const sf::IntRect& area,
|
|
|
|
const sf::Vector2f& offset) const;
|
2013-04-28 22:41:00 +00:00
|
|
|
|
|
|
|
private:
|
2013-05-01 19:32:03 +00:00
|
|
|
static const int MARGIN;
|
2013-05-08 09:19:21 +00:00
|
|
|
static const float LAYER_TILES;
|
|
|
|
static const float LAYER_ENEMIES;
|
|
|
|
|
2013-04-29 14:49:16 +00:00
|
|
|
World& mWorld;
|
|
|
|
Pathfinder& mPathfinder;
|
2013-05-01 19:32:03 +00:00
|
|
|
array mGenerated;
|
2013-04-11 18:44:00 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif /* DG_GENERATOR_H_ */
|