aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/cpp/WorldScene.cpp
diff options
context:
space:
mode:
authorNao Pross <naopross@thearcway.org>2018-02-12 19:49:28 +0100
committerNao Pross <naopross@thearcway.org>2018-02-12 19:49:28 +0100
commit978e96c319c4c240b5269c2dff8821a7e478f724 (patch)
treef4119494fba243d06ae7f51f784e6db59a70ea8b /src/main/cpp/WorldScene.cpp
parentMerge mafaldo's work (diff)
downloadSubconscious-old-978e96c319c4c240b5269c2dff8821a7e478f724.tar.gz
Subconscious-old-978e96c319c4c240b5269c2dff8821a7e478f724.zip
Fix pan
Diffstat (limited to 'src/main/cpp/WorldScene.cpp')
-rw-r--r--src/main/cpp/WorldScene.cpp11
1 files changed, 5 insertions, 6 deletions
diff --git a/src/main/cpp/WorldScene.cpp b/src/main/cpp/WorldScene.cpp
index c152db8..1be2097 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 + _panX, tile.y * _tileSize + _panY);
+ rect.setPosition(tile.x * _tileSize, tile.y * _tileSize);
_window.draw(rect);
}
}
@@ -51,13 +51,12 @@ 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
+ view.getCenter().x + dx,
+ view.getCenter().y + dy
);
+
+ _window.setView(view);
}