forked from libretro/Dinothawr
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtilemap.hpp
70 lines (55 loc) · 2.13 KB
/
tilemap.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#ifndef TILEMAP_HPP__
#define TILEMAP_HPP__
#include "surface.hpp"
#include "pugixml/pugixml.hpp"
#include <string>
#include <set>
#include <map>
namespace Blit
{
class Tilemap : public Renderable
{
public:
struct Layer
{
SurfaceCluster cluster;
std::map<std::string, std::string> attr;
std::string name;
};
Tilemap()
{
}
Tilemap(const std::string& path);
std::vector<Layer>& layers() { return m_layers; }
const std::vector<Layer>& layers() const { return m_layers; }
void pos(Pos position);
void render(RenderTarget& target) const;
void render_until_layer(unsigned index, RenderTarget& target) const;
void render_after_layer(unsigned index, RenderTarget& target) const;
int tile_width() const { return tilewidth; }
int tile_height() const { return tileheight; }
int tiles_width() const { return width; }
int tiles_height() const { return height; }
int pix_width() const { return width * tilewidth; }
int pix_height() const { return height * tileheight; }
const Surface* find_tile(unsigned layer, Pos pos) const;
const Surface* find_tile(const std::string& name, Pos pos) const;
Surface* find_tile(unsigned layer, Pos pos);
Surface* find_tile(const std::string& name, Pos pos);
const Layer* find_layer(const std::string& name) const;
int find_layer_index(const std::string& name) const;
Layer* find_layer(const std::string& name);
bool collision(Pos tile) const;
private:
std::vector<Layer> m_layers;
std::set<Pos> collisions;
int width, height, tilewidth, tileheight;
std::string dir;
void add_tileset(std::map<unsigned, Surface>& tiles,
pugi::xml_node node);
void add_layer(std::map<unsigned, Surface>& tiles,
pugi::xml_node node, int tilewidth, int tileheight);
std::map<std::string, std::string> get_attributes(pugi::xml_node, const std::string& child) const;
};
}
#endif