diff options
author | Paweł Redman <pawel.redman@gmail.com> | 2017-12-19 21:08:24 +0100 |
---|---|---|
committer | Paweł Redman <pawel.redman@gmail.com> | 2017-12-19 21:08:24 +0100 |
commit | 6dc7ae4f49931f721ad072cc72038cada78b147e (patch) | |
tree | d289fbce21085ddfa8a948b6b8004acde87a2433 /src/game/interface.cpp | |
parent | 1e702f4e99858d297607a7c1fde7d2df661ae324 (diff) |
Add a button for spawning more soldiers.
Diffstat (limited to 'src/game/interface.cpp')
-rw-r--r-- | src/game/interface.cpp | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/src/game/interface.cpp b/src/game/interface.cpp index 0ffdbab..0c2125b 100644 --- a/src/game/interface.cpp +++ b/src/game/interface.cpp @@ -62,6 +62,8 @@ void state_t::tick(double dt) window->setView(sf::View(view_center, view_size)); + wmouse = window->mapPixelToCoords(sf::Mouse::getPosition(*window)); + while (window->pollEvent(event)) { // FIXME: refactor this nested switch clusterfuck switch (event.type) { @@ -70,8 +72,6 @@ void state_t::tick(double dt) return; case sf::Event::MouseButtonPressed: - wmouse = window->mapPixelToCoords(sf::Vector2i(event.mouseButton.x, event.mouseButton.y)); - switch (event.mouseButton.button) { case sf::Mouse::Button::Left: select.selecting = true; @@ -140,6 +140,10 @@ void state_t::tick(double dt) } break; + case sf::Keyboard::Key::H: + game->spawn_soldier(wmouse); + break; + case sf::Keyboard::Key::F1: debug_draw_cmodels ^= 1; print("debug_draw_cmodels = " + std::to_string(debug_draw_cmodels)); @@ -165,9 +169,6 @@ void state_t::tick(double dt) } } - // Compute this _after_ the setView above. - wmouse = window->mapPixelToCoords(sf::Mouse::getPosition(*window)); - if (select.selecting) select.rect[1] = wmouse; } |