blob: a896b009f49b458500ddacf55357bde3df56f493 (
plain) (
blame)
| 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
 | #ifndef MAP_H_D95D6D47
#define MAP_H_D95D6D47
#include <string>
#include <string_view>
#include <vector>
#include "renderer.h"
#include "vector.h"
#include "step_type.h"
class Renderer;
struct Tile {
  unsigned int id = 0;
  bool flipHorizontal = false;
  bool flipVertical = false;
  bool blocked = false;
  StepType step = StepType::none;
};
struct Prototype {
  std::string name;
  vec2i pos;
  vec2i collisionOffset;
  vec2i collisionSize;
  std::string animationFilename;
  std::string interactionScript;
};
class Map {
public:
  Map(std::string_view filename, Renderer& renderer);
  const vec2i& getMapSize() const { return mapSize_; }
  const vec2i& getTileSize() const { return tileSize_; }
  const std::vector<std::vector<Tile>>& getLayers() const { return layers_; }
  int getTilesetTextureId() const { return tilesetTextureId_; }
  int getTilesetColumns() const { return tilesetColumns_; }
  bool isBlocked(int x, int y) const;
  StepType getStepType(int x, int y) const;
  const std::vector<Prototype>& getPrototypes() const { return prototypes_; }
private:
  vec2i mapSize_;
  vec2i tileSize_;
  std::vector<std::vector<Tile>> layers_;
  int tilesetTextureId_;
  int tilesetColumns_;
  std::vector<Prototype> prototypes_;
};
#endif /* end of include guard: MAP_H_D95D6D47 */
 |