diff options
author | Nao Pross <naopross@thearcway.org> | 2018-02-12 19:31:45 +0100 |
---|---|---|
committer | Nao Pross <naopross@thearcway.org> | 2018-02-12 19:31:45 +0100 |
commit | 43d0e11b4c9cd601f23cfe99a188ede598be418c (patch) | |
tree | 6a31fffae507997c0038177cbbccc984a468be04 /src/main/cpp/WorldScene.cpp | |
parent | Update gitignore to ignore ctags (diff) | |
download | Subconscious-old-43d0e11b4c9cd601f23cfe99a188ede598be418c.tar.gz Subconscious-old-43d0e11b4c9cd601f23cfe99a188ede598be418c.zip |
Fix zoom bug, add Scene.type member
Diffstat (limited to 'src/main/cpp/WorldScene.cpp')
-rw-r--r-- | src/main/cpp/WorldScene.cpp | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/src/main/cpp/WorldScene.cpp b/src/main/cpp/WorldScene.cpp index 973c6e6..209596b 100644 --- a/src/main/cpp/WorldScene.cpp +++ b/src/main/cpp/WorldScene.cpp @@ -1,6 +1,6 @@ #include "WorldScene.hpp" -WorldScene::WorldScene(sf::RenderWindow &window) : Scene(window) +WorldScene::WorldScene(sf::RenderWindow &window) : Scene(window, Scene::Type::WORLD) { _tileSize = DEFAULT_TILE_SIZE_PX; } @@ -12,6 +12,7 @@ void WorldScene::render() rect.setSize(sf::Vector2f(_tileSize, _tileSize)); rect.setFillColor(sf::Color::Green); + // negative thickness to make the outline toward inside rect.setOutlineThickness(-.5); rect.setOutlineColor(sf::Color::Black); @@ -24,7 +25,7 @@ void WorldScene::render() void WorldScene::resize(const sf::Event::SizeEvent &size) { auto oldView = _window.getView(); - sf::View resizedView(oldView.getCenter(), sf::Vector2f(size.width, size.height)); + sf::View resizedView(oldView.getCenter(), sf::Vector2f(size.width, size.height) / _zoom); _window.setView(resizedView); } @@ -35,21 +36,20 @@ void WorldScene::zoom(float factor) if (_zoom < MIN_ZOOM) { _zoom = MIN_ZOOM; + return; } if (_zoom > MAX_ZOOM) { _zoom = MAX_ZOOM; + return; } sf::View view = _window.getView(); - - view.setSize( - _window.getSize().x * 1 / _zoom, - _window.getSize().y * 1 / _zoom - ); - + view.setSize(static_cast<sf::Vector2f>(_window.getSize()) / _zoom); _window.setView(view); } void WorldScene::pan(int dx, int dy) -{} +{ + +} |