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

62 lines
1,019 B
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 "../abstract/Sprite.h"
class World;
2012-10-14 16:14:06 +00:00
2013-04-27 19:31:08 +00:00
class TileManager {
2012-10-14 16:14:06 +00:00
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:
static const sf::Vector2i TILE_SIZE; //< Tile size in pixels.
2012-10-14 16:14:06 +00:00
public:
explicit TileManager(World& world);
2012-10-14 16:14:06 +00:00
void insertTile(const TilePosition& position, Type type);
2013-04-04 20:44:15 +00:00
bool raycast(const sf::Vector2f& lineStart,
const sf::Vector2f& lineEnd) const;
2012-10-14 16:14:06 +00:00
private:
class Tile;
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:
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:
Type mType;
2012-10-14 16:14:06 +00:00
};
#endif /* DG_TILEMANAGER_H_ */