aboutsummaryrefslogtreecommitdiff
path: root/Simulation/Camera.hpp
diff options
context:
space:
mode:
authorPaul Oliver <contact@pauloliver.dev>2024-02-29 19:27:35 +0100
committerPaul Oliver <contact@pauloliver.dev>2024-02-29 19:27:49 +0100
commit17909d029c6a8872b2fddf4e171d7925bbbe9c5c (patch)
treecbb08af84cd68d24acc362d593a2048b0fa79689 /Simulation/Camera.hpp
Initial commitHEADmaster
Diffstat (limited to 'Simulation/Camera.hpp')
-rw-r--r--Simulation/Camera.hpp42
1 files changed, 42 insertions, 0 deletions
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 <SFML/Graphics.hpp>
+#include <Box2D.h>
+
+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__