From a645524d19bb9183d4eece72bf8945bba4bed3a0 Mon Sep 17 00:00:00 2001 From: Kelly Rauchenberger Date: Tue, 16 Feb 2021 22:03:10 -0500 Subject: Added scriptable camera panning --- src/camera_system.h | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'src/camera_system.h') diff --git a/src/camera_system.h b/src/camera_system.h index 37ff8b4..a2dee93 100644 --- a/src/camera_system.h +++ b/src/camera_system.h @@ -24,6 +24,13 @@ public: void unlockCamera() { locked_ = false; } + // Pans over to the provided sprite over the provided amount of time. + // - length is in milliseconds + // Automatically locks the camera. + void panToSprite(int targetId, int length); + + bool isPanning() const { return panning_; } + void tick(double dt) override; void destroySprite(int spriteId) override; @@ -31,12 +38,21 @@ public: void clearSpriteCache() override; private: + + vec2i calculatePosWithCenter(vec2i center) const; + Game& game_; vec2i pos_; vec2i fov_ { CANVAS_WIDTH, CANVAS_HEIGHT }; int followingSprite_ = -1; bool locked_ = true; + + bool panning_ = false; + vec2i panStart_; + vec2i panEnd_; + double panLength_ = 0.0; + double panThus_ = 0.0; }; #endif /* end of include guard: CAMERA_SYSTEM_H_D52ADAD3 */ -- cgit 1.4.1