LPCGame
A Simple 2d Game Engine
 All Classes Namespaces Functions Variables Enumerations Enumerator Pages
camera.h
1 #ifndef CAMERA_H
2 #define CAMERA_H
3 
4 #include <memory>
5 #include <vector>
6 #include "external/json/json.h"
7 #include "base.h"
8 #include "window.h"
9 #include "entity.h"
10 
12 
16 struct CameraPan {
17  std::string name;
18  Vector2i destination;
19  int speed;
20 };
21 
23 
27 class Camera {
28 public:
29  Camera();
30  ~Camera();
35  void SetFocus(std::shared_ptr<Entity> obj);
37  void Update();
43  bool InCamera(Rectf box) const;
49  void Move(Vector2f v);
55  void Move(float deltaT);
60  void Pan(std::string name);
65  std::string Scene();
72  void SetBox(Rectf box);
74  Rectf Box() const;
80  void SetSceneBox(Rectf box);
82  Rectf SceneBox() const;
89  Vector2f Offset() const;
94  Vector2f Centering() const;
99  Json::Value Save();
104  void Load(Json::Value val);
106  bool operator == (const Camera &c) const;
107  bool operator != (const Camera &c) const;
108 
109 private:
110  std::weak_ptr<Entity> mFocus;
111  Rectf mBox, mSceneBox;
112  std::vector<CameraPan> mPans;
113  int mActivePan;
114  std::string mScene;
115 };
116 
117 #endif