Last active
December 19, 2015 23:09
-
-
Save farnoy/6032872 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
bool exiter::is_handling(const sf::Event::EventType& ev_type) const { | |
if (ev_type == sf::Event::Closed) | |
return true; | |
if (ev_type == sf::Event::KeyPressed) | |
return true; | |
else | |
return controller::is_handling(ev_type); | |
} | |
bool exiter::handle(const sf::Event& event, runner& runner) { | |
if (event.type == sf::Event::Closed || | |
event.key.code == sf::Keyboard::Key::Escape) { | |
runner.get_renderer()->get_window()->close(); | |
return false; // stop propagating | |
} else | |
return true; // continue propagating | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
bool actor_spawner::is_handling(const sf::Event::EventType& ev_type) const { | |
if (ev_type == sf::Event::MouseButtonPressed) | |
return true; | |
else | |
return controller::is_handling(ev_type); | |
} | |
bool actor_spawner::handle(const sf::Event& event, runner& runner) { | |
if (event.mouseButton.button == sf::Mouse::Button::Left) { | |
runner.get_entity_manager()->add(new testcircle); | |
return false; // stop propagating | |
} else | |
return controller::handle(event, runner); // continue propagating | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
bool coordinate_debugger::is_handling( | |
const sf::Event::EventType& ev_type) const { | |
if (ev_type == sf::Event::MouseButtonPressed) | |
return true; | |
if (ev_type == sf::Event::MouseButtonReleased) | |
return true; | |
if (_point && ev_type == sf::Event::MouseMoved) | |
return true; | |
else | |
return controller::is_handling(ev_type); | |
} | |
bool coordinate_debugger::handle(const sf::Event& event, runner& runner) { | |
if (event.type == sf::Event::MouseButtonPressed) { | |
_point = std::make_shared<entities::debug_point>(sf::Vector2f { | |
static_cast<float>(event.mouseButton.x), | |
static_cast<float>(event.mouseButton.y) | |
}); | |
runner.get_entity_manager()->add(_point); | |
return false; | |
} else if (event.type == sf::Event::MouseButtonReleased) { | |
runner.get_entity_manager()->remove(_point); | |
_point.reset(); | |
return false; | |
} else if (event.type == sf::Event::MouseMoved) { | |
_point->shape.setPosition(sf::Vector2f { | |
static_cast<float>(event.mouseMove.x), | |
static_cast<float>(event.mouseMove.y) | |
}); | |
} | |
return controller::handle(event, runner); // continue propagating | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment