summaryrefslogtreecommitdiff
path: root/src/game/interface.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/game/interface.cpp')
-rw-r--r--src/game/interface.cpp20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/game/interface.cpp b/src/game/interface.cpp
index 67f5482..6512576 100644
--- a/src/game/interface.cpp
+++ b/src/game/interface.cpp
@@ -27,6 +27,20 @@ void state_t::tick(double dt)
size = window->getSize();
+ if (!game->selected_units.size())
+ camera.following = false;
+
+ if (camera.following) {
+ v2f_t goal(0, 0);
+
+ for (entity_t *ent : game->selected_units)
+ goal += ent->render_bounds.center();
+ goal /= game->selected_units.size();
+
+ camera.center[0] = expfade(camera.center[0], goal[0], 20, dt);
+ camera.center[1] = expfade(camera.center[1], goal[1], 20, dt);
+ }
+
camera.zoom = expfade(camera.zoom, camera.target_zoom, 15, dt);
{
@@ -67,6 +81,7 @@ void state_t::tick(double dt)
break;
case sf::Mouse::Button::Middle:
+ camera.following = false;
camera.panning = true;
camera.pan_ref = wmouse;
break;
@@ -110,6 +125,11 @@ void state_t::tick(double dt)
else
print(text::get(text::UNPAUSED));
break;
+
+ case sf::Keyboard::Key::F:
+ camera.following = true;
+ break;
+
case sf::Keyboard::Key::F1:
debug_draw_cmodels ^= 1;
print("debug_draw_cmodels = " + std::to_string(debug_draw_cmodels));