#include "camera_system.h" #include "sprite.h" #include "game.h" #include "map.h" void CameraSystem::tick(double dt) { if (!locked_) { const Sprite& follow = game_.getSprite(followingSprite_); const Map& map = game_.getMap(); vec2i mapBounds = map.getMapSize() * map.getTileSize(); pos_ = follow.loc() - (fov_ / 2); if (pos_.x() < 0) { pos_.x() = 0; } if (pos_.y() < 0) { pos_.y() = 0; } if (pos_.x() + fov_.w() >= mapBounds.w()) { pos_.x() = mapBounds.w() - fov_.w() - 1; } if (pos_.y() + fov_.h() >= mapBounds.h()) { pos_.y() = mapBounds.h() - fov_.h() - 1; } } }