diff options
author | Nao Pross <naopross@thearcway.org> | 2018-02-12 19:40:13 +0100 |
---|---|---|
committer | Nao Pross <naopross@thearcway.org> | 2018-02-12 19:40:13 +0100 |
commit | f8ca0da580a1589742a541a14b530e39282a5c9b (patch) | |
tree | 1758eb024bcad447f24d758e0fc4c295f0468933 /src/main/cpp/WorldScene.cpp | |
parent | Fix zoom bug, add Scene.type member (diff) | |
parent | add pan (diff) | |
download | Subconscious-old-f8ca0da580a1589742a541a14b530e39282a5c9b.tar.gz Subconscious-old-f8ca0da580a1589742a541a14b530e39282a5c9b.zip |
Merge mafaldo's work
Diffstat (limited to 'src/main/cpp/WorldScene.cpp')
-rw-r--r-- | src/main/cpp/WorldScene.cpp | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/src/main/cpp/WorldScene.cpp b/src/main/cpp/WorldScene.cpp index 209596b..c152db8 100644 --- a/src/main/cpp/WorldScene.cpp +++ b/src/main/cpp/WorldScene.cpp @@ -17,7 +17,7 @@ void WorldScene::render() rect.setOutlineColor(sf::Color::Black); for (const Tile &tile : map.tiles()) { - rect.setPosition(tile.x * _tileSize, tile.y * _tileSize); + rect.setPosition(tile.x * _tileSize + _panX, tile.y * _tileSize + _panY); _window.draw(rect); } } @@ -51,5 +51,13 @@ void WorldScene::zoom(float factor) void WorldScene::pan(int dx, int dy) { + _panX = _panX + dx; + _panY = _panY + dy; + sf::View view = _window.getView(); + + view.setCenter( + view.getCenter().x + _panX, + view.getCenter().y + _panY + ); } |