From d3e8495212f9008f0c2650fb5ee628b464ca5ac0 Mon Sep 17 00:00:00 2001 From: Nao Pross Date: Mon, 12 Feb 2018 00:13:39 +0100 Subject: Handle WindowResize event and add zoom --- src/main/headers/Scene.hpp | 14 +++++++++++++- src/main/headers/WorldScene.hpp | 7 ++++--- 2 files changed, 17 insertions(+), 4 deletions(-) (limited to 'src/main/headers') diff --git a/src/main/headers/Scene.hpp b/src/main/headers/Scene.hpp index 2b19d31..b7a46e6 100644 --- a/src/main/headers/Scene.hpp +++ b/src/main/headers/Scene.hpp @@ -6,7 +6,19 @@ class Scene { public: - virtual void render(sf::RenderWindow &window) = 0; + constexpr static float MAX_ZOOM = 10; + constexpr static float MIN_ZOOM = .1; + + virtual void render() = 0; + virtual void resize(const sf::Event::SizeEvent &size) = 0; + + virtual void zoom(float factor) {} + +protected: + float _zoom = 1; + sf::RenderWindow &_window; + + Scene(sf::RenderWindow &window) : _window(window) {} }; #endif diff --git a/src/main/headers/WorldScene.hpp b/src/main/headers/WorldScene.hpp index acdda63..09f3120 100644 --- a/src/main/headers/WorldScene.hpp +++ b/src/main/headers/WorldScene.hpp @@ -14,11 +14,12 @@ public: constexpr static int ZOOM_MAX = 100; constexpr static int DEFAULT_TILE_SIZE_PX = 20; - WorldScene(); + WorldScene(sf::RenderWindow &window); - virtual void render(sf::RenderWindow &window); + virtual void render(); + virtual void resize(const sf::Event::SizeEvent &size); - virtual void zoom(int value); + virtual void zoom(float factor); virtual void pan(int dx, int dy); private: -- cgit v1.2.1