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"
#include "../types/Vector.h"
#include "../types/String.h"
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.
*/
typedef Vector2i TilePosition;
// Public variables.
public:
/// The size of a single tile (pixels).
static const Vector2i TILE_SIZE;
// Public functions.
public:
TileManager(World& world);
2012-10-14 16:14:06 +00:00
void setTile(const TilePosition& position, Type type);
// 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;
static String getConfig(Type type);
// Private variables.
private:
Type mType;
2012-10-14 16:14:06 +00:00
};
#endif /* DG_TILEMANAGER_H_ */