aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/cpp
diff options
context:
space:
mode:
authorNao Pross <naopross@thearcway.org>2018-02-12 20:33:48 +0100
committerNao Pross <naopross@thearcway.org>2018-02-12 20:33:48 +0100
commit92bec13dec53933a9cf8045ab486b47dc13fe46f (patch)
treede140535d5e6941bfd0f251e851f8a331ce6edf2 /src/main/cpp
parentFix pan (diff)
downloadSubconscious-old-92bec13dec53933a9cf8045ab486b47dc13fe46f.tar.gz
Subconscious-old-92bec13dec53933a9cf8045ab486b47dc13fe46f.zip
Remove Actor::Type and Scene::Type in favor of dynamic_cast<T>()
Diffstat (limited to '')
-rw-r--r--src/main/cpp/Actor.cpp4
-rw-r--r--src/main/cpp/Subconscious.cpp21
-rw-r--r--src/main/cpp/WorldScene.cpp2
3 files changed, 13 insertions, 14 deletions
diff --git a/src/main/cpp/Actor.cpp b/src/main/cpp/Actor.cpp
index 219488d..a6dc597 100644
--- a/src/main/cpp/Actor.cpp
+++ b/src/main/cpp/Actor.cpp
@@ -1,7 +1,7 @@
#include "Actor.hpp"
-Actor::Actor(std::string _name, unsigned _maxHp, Type _type) :
- name(_name), maxHp(_maxHp), type(_type)
+Actor::Actor(std::string _name, unsigned _maxHp) :
+ name(_name), maxHp(_maxHp)
{}
Actor::~Actor()
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;
diff --git a/src/main/cpp/WorldScene.cpp b/src/main/cpp/WorldScene.cpp
index 1be2097..8887f6f 100644
--- a/src/main/cpp/WorldScene.cpp
+++ b/src/main/cpp/WorldScene.cpp
@@ -1,6 +1,6 @@
#include "WorldScene.hpp"
-WorldScene::WorldScene(sf::RenderWindow &window) : Scene(window, Scene::Type::WORLD)
+WorldScene::WorldScene(sf::RenderWindow &window) : Scene(window)
{
_tileSize = DEFAULT_TILE_SIZE_PX;
}