aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/main/cpp/Subconscious.cpp8
-rw-r--r--src/main/cpp/WorldScene.cpp11
-rw-r--r--src/main/headers/WorldScene.hpp3
3 files changed, 9 insertions, 13 deletions
diff --git a/src/main/cpp/Subconscious.cpp b/src/main/cpp/Subconscious.cpp
index 9765f2f..a5f8620 100644
--- a/src/main/cpp/Subconscious.cpp
+++ b/src/main/cpp/Subconscious.cpp
@@ -35,25 +35,25 @@ void Subconscious::run()
switch (event.key.code) {
case sf::Keyboard::Up:
if (_currentScene->type == Scene::Type::WORLD) {
- static_cast<WorldScene*>(_currentScene)->pan(0, 10);
+ static_cast<WorldScene*>(_currentScene)->pan(0, -10);
}
break;
case sf::Keyboard::Down:
if (_currentScene->type == Scene::Type::WORLD) {
- static_cast<WorldScene*>(_currentScene)->pan(0, -10);
+ static_cast<WorldScene*>(_currentScene)->pan(0, 10);
}
break;
case sf::Keyboard::Left:
if (_currentScene->type == Scene::Type::WORLD) {
- static_cast<WorldScene*>(_currentScene)->pan(10, 0);
+ static_cast<WorldScene*>(_currentScene)->pan(-10, 0);
}
break;
case sf::Keyboard::Right:
if (_currentScene->type == Scene::Type::WORLD) {
- static_cast<WorldScene*>(_currentScene)->pan(-10, 0);
+ static_cast<WorldScene*>(_currentScene)->pan(10, 0);
}
break;
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);
}
diff --git a/src/main/headers/WorldScene.hpp b/src/main/headers/WorldScene.hpp
index ec12930..d21d885 100644
--- a/src/main/headers/WorldScene.hpp
+++ b/src/main/headers/WorldScene.hpp
@@ -26,9 +26,6 @@ private:
Map map;
unsigned _tileSize;
-
- int _panX = 0;
- int _panY = 0;
};
#endif