summary refs log tree commit diff stats
path: root/src/game.h
diff options
context:
space:
mode:
authorKelly Rauchenberger <fefferburbia@gmail.com>2021-02-02 16:51:22 -0500
committerKelly Rauchenberger <fefferburbia@gmail.com>2021-02-02 16:51:22 -0500
commitb628c80f988c1fb250b94b17dca8e082bc4c1d0b (patch)
treeb4de344e1d8d28a88aa1a1dbc381e07f03707fff /src/game.h
parenta475b843e7d37f128ce30140d193f0312aa70c9c (diff)
downloadtanetane-b628c80f988c1fb250b94b17dca8e082bc4c1d0b.tar.gz
tanetane-b628c80f988c1fb250b94b17dca8e082bc4c1d0b.tar.bz2
tanetane-b628c80f988c1fb250b94b17dca8e082bc4c1d0b.zip
Added moving camera
Diffstat (limited to 'src/game.h')
-rw-r--r--src/game.h21
1 files changed, 21 insertions, 0 deletions
diff --git a/src/game.h b/src/game.h index 2c1680a..a717d53 100644 --- a/src/game.h +++ b/src/game.h
@@ -7,6 +7,7 @@
7#include <memory> 7#include <memory>
8#include "sprite.h" 8#include "sprite.h"
9#include "map.h" 9#include "map.h"
10#include "consts.h"
10 11
11struct Input { 12struct Input {
12 bool left = false; 13 bool left = false;
@@ -60,11 +61,31 @@ public:
60 61
61 const Map& getMap() const { return *map_; } 62 const Map& getMap() const { return *map_; }
62 63
64 // Camera
65
66 const vec2i& getCameraPosition() const { return cameraPos_; }
67
68 const vec2i& getFieldOfView() const { return cameraFov_; }
69
70 void setFollowingSprite(int spriteId) { followingSprite_ = spriteId; }
71
72 void lockCamera() { cameraLocked_ = true; }
73
74 void unlockCamera() { cameraLocked_ = false; }
75
76 void tick();
77
63private: 78private:
64 79
65 std::vector<Sprite> sprites_; 80 std::vector<Sprite> sprites_;
66 std::set<std::tuple<int, int>> spritesByY_; 81 std::set<std::tuple<int, int>> spritesByY_;
67 std::unique_ptr<Map> map_; 82 std::unique_ptr<Map> map_;
83
84 // Camera
85 vec2i cameraPos_;
86 vec2i cameraFov_ { CANVAS_WIDTH, CANVAS_HEIGHT };
87 int followingSprite_;
88 bool cameraLocked_ = true;
68}; 89};
69 90
70#endif /* end of include guard: GAME_H_E6F1396E */ 91#endif /* end of include guard: GAME_H_E6F1396E */