aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/cpp/Subconscious.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/cpp/Subconscious.cpp')
-rw-r--r--src/main/cpp/Subconscious.cpp21
1 files changed, 10 insertions, 11 deletions
diff --git a/src/main/cpp/Subconscious.cpp b/src/main/cpp/Subconscious.cpp
index a5f8620..5d04e5c 100644
--- a/src/main/cpp/Subconscious.cpp
+++ b/src/main/cpp/Subconscious.cpp
@@ -34,26 +34,26 @@ void Subconscious::run()
case sf::Event::KeyPressed:
switch (event.key.code) {
case sf::Keyboard::Up:
- if (_currentScene->type == Scene::Type::WORLD) {
- static_cast<WorldScene*>(_currentScene)->pan(0, -10);
+ if (WorldScene *worldScene = dynamic_cast<WorldScene*>(_currentScene)) {
+ worldScene->pan(0, -10);
}
break;
case sf::Keyboard::Down:
- if (_currentScene->type == Scene::Type::WORLD) {
- static_cast<WorldScene*>(_currentScene)->pan(0, 10);
+ if (WorldScene *worldScene = dynamic_cast<WorldScene*>(_currentScene)) {
+ worldScene->pan(0, 10);
}
break;
case sf::Keyboard::Left:
- if (_currentScene->type == Scene::Type::WORLD) {
- static_cast<WorldScene*>(_currentScene)->pan(-10, 0);
+ if (WorldScene *worldScene = dynamic_cast<WorldScene*>(_currentScene)) {
+ worldScene->pan(-10, 0);
}
break;
case sf::Keyboard::Right:
- if (_currentScene->type == Scene::Type::WORLD) {
- static_cast<WorldScene*>(_currentScene)->pan(10, 0);
+ if (WorldScene *worldScene = dynamic_cast<WorldScene*>(_currentScene)) {
+ worldScene->pan(10, 0);
}
break;
@@ -83,9 +83,8 @@ void Subconscious::run()
//
// std::cout << std::fixed << std::setprecision(3)
// << event.mouseWheelScroll.delta << std::endl;
-
- if (_currentScene->type == Scene::Type::WORLD) {
- static_cast<WorldScene*>(_currentScene)->zoom(event.mouseWheelScroll.delta/10.0);
+ if (WorldScene *worldScene = dynamic_cast<WorldScene*>(_currentScene)) {
+ worldScene->zoom(event.mouseWheelScroll.delta/10.0);
}
break;