From 24918837c3ff9026d228657d14852c9cf39a5644 Mon Sep 17 00:00:00 2001 From: Kelly Rauchenberger Date: Wed, 3 Feb 2021 01:11:31 -0500 Subject: Added camera system --- src/camera_system.h | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 src/camera_system.h (limited to 'src/camera_system.h') diff --git a/src/camera_system.h b/src/camera_system.h new file mode 100644 index 0000000..3eb8374 --- /dev/null +++ b/src/camera_system.h @@ -0,0 +1,38 @@ +#ifndef CAMERA_SYSTEM_H_D52ADAD3 +#define CAMERA_SYSTEM_H_D52ADAD3 + +#include "consts.h" +#include "system.h" +#include "vector.h" + +class Game; + +class CameraSystem : public System { +public: + + static constexpr SystemKey Key = SystemKey::Camera; + + CameraSystem(Game& game) : game_(game) {} + + const vec2i& getCameraPosition() const { return pos_; } + + const vec2i& getFieldOfView() const { return fov_; } + + void setFollowingSprite(int spriteId) { followingSprite_ = spriteId; } + + void lockCamera() { locked_ = true; } + + void unlockCamera() { locked_ = false; } + + void tick(double dt) override; + +private: + Game& game_; + + vec2i pos_; + vec2i fov_ { CANVAS_WIDTH, CANVAS_HEIGHT }; + int followingSprite_; + bool locked_ = true; +}; + +#endif /* end of include guard: CAMERA_SYSTEM_H_D52ADAD3 */ -- cgit 1.4.1