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/sprites/TileManager.h

79 lines
1.3 KiB
C
Raw Normal View History

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 <map>
#include <vector>
#include "../World.h"
2012-10-14 16:14:06 +00:00
#include "../abstract/Sprite.h"
2012-12-22 14:10:26 +00:00
#include <string>
2012-10-14 16:14:06 +00:00
class World;
2012-10-14 16:14:06 +00:00
class Sprite;
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:
TileManager(World& world);
2012-10-14 16:14:06 +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:
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:
2012-12-22 13:56:17 +00:00
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.
private:
Type mType;
2012-10-14 16:14:06 +00:00
};
#endif /* DG_TILEMANAGER_H_ */