2012-10-14 16:14:06 +00:00
|
|
|
/*
|
|
|
|
* TileManager.h
|
|
|
|
*
|
|
|
|
* Created on: 08.08.2012
|
|
|
|
* Author: Felix
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef DG_TILEMANAGER_H_
|
|
|
|
#define DG_TILEMANAGER_H_
|
|
|
|
|
|
|
|
#include "../abstract/Sprite.h"
|
|
|
|
|
2012-12-22 00:14:30 +00:00
|
|
|
class World;
|
2012-10-14 16:14:06 +00:00
|
|
|
|
|
|
|
class TileManager : public sf::Drawable {
|
|
|
|
// Public types.
|
|
|
|
public:
|
|
|
|
enum class Type {
|
|
|
|
FLOOR,
|
|
|
|
WALL
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Uses the length/width of a tile as a unit.
|
|
|
|
*/
|
2012-12-22 14:10:26 +00:00
|
|
|
typedef sf::Vector2i TilePosition;
|
2012-10-14 16:14:06 +00:00
|
|
|
|
|
|
|
// Public variables.
|
|
|
|
public:
|
|
|
|
/// The size of a single tile (pixels).
|
2012-12-22 14:10:26 +00:00
|
|
|
static const sf::Vector2i TILE_SIZE;
|
2012-10-14 16:14:06 +00:00
|
|
|
|
|
|
|
// Public functions.
|
|
|
|
public:
|
2013-03-30 15:39:46 +00:00
|
|
|
explicit TileManager(World& world);
|
2012-10-14 16:14:06 +00:00
|
|
|
|
2013-03-03 20:26:29 +00:00
|
|
|
void insertTile(const TilePosition& position, Type type);
|
|
|
|
void removeTile(const TilePosition& position);
|
2012-10-14 16:14:06 +00:00
|
|
|
|
|
|
|
// Private types.
|
|
|
|
private:
|
|
|
|
class Tile;
|
|
|
|
|
|
|
|
// Private functions.
|
|
|
|
private:
|
|
|
|
void draw(sf::RenderTarget& target, sf::RenderStates states) const;
|
|
|
|
|
|
|
|
// Private variables.
|
|
|
|
private:
|
2012-12-22 00:14:30 +00:00
|
|
|
World& mWorld;
|
2012-12-22 13:56:17 +00:00
|
|
|
std::vector<std::shared_ptr<Tile> > mTiles;
|
2012-10-14 16:14:06 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Holds information about a single tile.
|
|
|
|
*/
|
|
|
|
class TileManager::Tile : public Sprite {
|
|
|
|
// Public functions.
|
|
|
|
public:
|
2013-03-30 15:39:46 +00:00
|
|
|
explicit Tile(Type type, const TilePosition& position);
|
2012-10-14 16:14:06 +00:00
|
|
|
|
|
|
|
Type getType() const;
|
|
|
|
TilePosition getTilePosition() const;
|
|
|
|
|
2012-12-22 14:10:26 +00:00
|
|
|
static std::string getConfig(Type type);
|
2012-10-14 16:14:06 +00:00
|
|
|
|
|
|
|
// Private variables.
|
2012-09-09 20:50:15 +00:00
|
|
|
private:
|
|
|
|
Type mType;
|
2012-10-14 16:14:06 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif /* DG_TILEMANAGER_H_ */
|