diff options
Diffstat (limited to 'src/game.cpp')
| -rw-r--r-- | src/game.cpp | 22 |
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 | |||
| 10 | void 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 | } | ||
