aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/cpp/WorldScene.cpp
diff options
context:
space:
mode:
authormafaldo <mafaldo@heavyhammer.home>2018-02-12 19:27:49 +0100
committermafaldo <mafaldo@heavyhammer.home>2018-02-12 19:27:49 +0100
commit07ac0fe25109717d4d7f9bcc7ae313a25b839cb0 (patch)
tree509c740828e2cae12e8e5de48c13219349d43d3b /src/main/cpp/WorldScene.cpp
parentEdit makefile to build and run c++ by default (diff)
downloadSubconscious-old-07ac0fe25109717d4d7f9bcc7ae313a25b839cb0.tar.gz
Subconscious-old-07ac0fe25109717d4d7f9bcc7ae313a25b839cb0.zip
add pan
Diffstat (limited to 'src/main/cpp/WorldScene.cpp')
-rw-r--r--src/main/cpp/WorldScene.cpp14
1 files changed, 12 insertions, 2 deletions
diff --git a/src/main/cpp/WorldScene.cpp b/src/main/cpp/WorldScene.cpp
index 973c6e6..cefeda4 100644
--- a/src/main/cpp/WorldScene.cpp
+++ b/src/main/cpp/WorldScene.cpp
@@ -16,7 +16,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);
}
}
@@ -52,4 +52,14 @@ 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
+ );
+}