summary refs log tree commit diff stats
path: root/src/game.cpp
diff options
context:
space:
mode:
authorKelly Rauchenberger <fefferburbia@gmail.com>2021-02-03 01:11:31 -0500
committerKelly Rauchenberger <fefferburbia@gmail.com>2021-02-03 01:11:31 -0500
commit24918837c3ff9026d228657d14852c9cf39a5644 (patch)
treebe131a43eb30f164bd70f542cfcaec688fbc3d51 /src/game.cpp
parentf449345e3aeb599eb497dfeeac7027cf4d1de515 (diff)
downloadtanetane-24918837c3ff9026d228657d14852c9cf39a5644.tar.gz
tanetane-24918837c3ff9026d228657d14852c9cf39a5644.tar.bz2
tanetane-24918837c3ff9026d228657d14852c9cf39a5644.zip
Added camera system
Diffstat (limited to 'src/game.cpp')
-rw-r--r--src/game.cpp22
1 files changed, 0 insertions, 22 deletions
diff --git a/src/game.cpp b/src/game.cpp index 42dbd64..bb20d74 100644 --- a/src/game.cpp +++ b/src/game.cpp
@@ -6,25 +6,3 @@ int Game::addSprite(Sprite sprite) {
6 spriteIds_.push_back(id); 6 spriteIds_.push_back(id);
7 return id; 7 return id;
8} 8}
9
10void Game::tick() {
11 if (!cameraLocked_) {
12 const Sprite& follow = getSprite(followingSprite_);
13 vec2i mapBounds = map_->getMapSize() * map_->getTileSize();
14
15 cameraPos_ = follow.loc() - (cameraFov_ / 2);
16
17 if (cameraPos_.x() < 0) {
18 cameraPos_.x() = 0;
19 }
20 if (cameraPos_.y() < 0) {
21 cameraPos_.y() = 0;
22 }
23 if (cameraPos_.x() + cameraFov_.w() >= mapBounds.w()) {
24 cameraPos_.x() = mapBounds.w() - cameraFov_.w() - 1;
25 }
26 if (cameraPos_.y() + cameraFov_.h() >= mapBounds.h()) {
27 cameraPos_.y() = mapBounds.h() - cameraFov_.h() - 1;
28 }
29 }
30}