From 17909d029c6a8872b2fddf4e171d7925bbbe9c5c Mon Sep 17 00:00:00 2001 From: Paul Oliver Date: Thu, 29 Feb 2024 19:27:35 +0100 Subject: Initial commit --- Simulation/Camera.hpp | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 Simulation/Camera.hpp (limited to 'Simulation/Camera.hpp') diff --git a/Simulation/Camera.hpp b/Simulation/Camera.hpp new file mode 100644 index 0000000..b6ee8a9 --- /dev/null +++ b/Simulation/Camera.hpp @@ -0,0 +1,42 @@ +#ifndef __CAMERA_HPP__ +#define __CAMERA_HPP__ + +#include +#include + +class SimBase; + +class Camera +{ +public: + void create(SimBase *sim); + void onResize(); + void onClick(); + void shift(const sf::Vector2f &newTrgtCrds, int zoomInOut = 0, bool release = true); + void update(); + + sf::Vector2f getCrds() const { return currentCrds; } + float getZoom() const { return zoom; } + +private: + SimBase *hSim = nullptr; + + float defaultZoom = 0.f; + float zoom = 0.f; + float prevZoom = 0.f; + float trgtZoom = 0.f; + sf::Vector2f currentCrds = { 0.f, 0.f }; + sf::Vector2f prevCrds = { 0.f, 0.f }; + sf::Vector2f trgtCrds = { 0.f, 0.f }; + unsigned step = 0; + bool isOnFollow = false; + b2Body *trgtBody = nullptr; + + friend class ContactListener; + friend class Zapper; + friend class Pellet; + friend class Guppie; + friend class Corpse; +}; + +#endif // __CAMERA_HPP__ -- cgit v1.2.1