YAGE  v0.1.3.0
Yet Another Game Engine
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
spritesheet.h
Go to the documentation of this file.
1 
9 
11 #ifndef YAGE_SPRITESHEET_H
12 #define YAGE_SPRITESHEET_H
13 
18 #include "../data/texture.h"
19 
20 #include <rapidjson/reader.h>
21 
22 #include <map>
23 #include <string>
24 
25 namespace yage
26 {
27 
28 namespace details
29 {
30 
31 struct Coordinate {
32  int x;
33  int y;
34  int width;
35  int height;
36 
37  Coordinate() = default;
38 
39  Coordinate(int x_i, int y_i, int width_i, int height_i)
40  : x(x_i), y(y_i), width(width_i), height(height_i)
41  {
42  }
43 };
44 
45 typedef std::map<std::string, details::Coordinate> SpriteMap;
46 
47 } // namespace details
48 
50 {
51 public:
52  SpriteSheet(std::string pngFileName, std::string jsonFileName);
53 
54  void sprite(std::string spriteName) const;
55  std::string fileContent(std::string jsonFileName) const;
56 
57 private:
58  Texture texture_;
59  details::SpriteMap fileLocations_;
60 
61  details::SpriteMap parseJson(int &width, int &height,
62  std::string jsonContent) const;
63 };
64 
65 } // namespace yage
66 
67 #endif
Definition: spritesheet.h:49
Coordinate(int x_i, int y_i, int width_i, int height_i)
Definition: spritesheet.h:39
SpriteSheet(std::string pngFileName, std::string jsonFileName)
Definition: spritesheet.cpp:28
int x
Definition: spritesheet.h:32
std::map< std::string, details::Coordinate > SpriteMap
Definition: spritesheet.h:45
int width
Definition: spritesheet.h:34
void sprite(std::string spriteName) const
int height
Definition: spritesheet.h:35
Definition: texture.h:17
Definition: spritesheet.h:31
int y
Definition: spritesheet.h:33
std::string fileContent(std::string jsonFileName) const
Definition: spritesheet.cpp:41