This repository has been archived on 2019-12-07. You can view files and clone it, but cannot push or open issues or pull requests.
dungeon-gunner/source/generator/Generator.h
2013-05-01 21:32:03 +02:00

44 lines
1 KiB
C++

/*
* Generator.h
*
* Created on: 07.04.2013
* Author: Felix
*/
#ifndef DG_GENERATOR_H_
#define DG_GENERATOR_H_
#include <SFML/Graphics.hpp>
#include "../sprites/Tile.h"
class World;
class Pathfinder;
class Generator {
public:
explicit Generator(World& world, Pathfinder& pathfinder);
void generateTiles(const sf::IntRect& area);
sf::Vector2f getPlayerSpawn() const;
private:
typedef Tile::Type type;
typedef std::map<int, std::map<int, type> > array;
private:
sf::Vector2i findClosestFloor(const sf::Vector2i& position) const;
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;
private:
static const int MARGIN;
World& mWorld;
Pathfinder& mPathfinder;
array mGenerated;
};
#endif /* DG_GENERATOR_H_ */