From 6dc7ae4f49931f721ad072cc72038cada78b147e Mon Sep 17 00:00:00 2001 From: Paweł Redman Date: Tue, 19 Dec 2017 21:08:24 +0100 Subject: Add a button for spawning more soldiers. --- src/game/interface.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'src/game/interface.cpp') 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; } -- cgit