summaryrefslogtreecommitdiff
path: root/src/game.cpp
diff options
context:
space:
mode:
authorPaweł Redman <pawel.redman@gmail.com>2017-11-21 13:27:49 +0100
committerPaweł Redman <pawel.redman@gmail.com>2017-11-21 13:28:21 +0100
commitd61f45073e36fb655f08dc778413cc54acef558f (patch)
tree9823d98c3453ae13267f0a48eafbc675c93be27c /src/game.cpp
parent9454caf1d99f3d324adab4bc49c6c0609a5faebd (diff)
Snap unit movement to tile centers.
Diffstat (limited to 'src/game.cpp')
-rw-r--r--src/game.cpp7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/game.cpp b/src/game.cpp
index a3af9ed..8daa7d0 100644
--- a/src/game.cpp
+++ b/src/game.cpp
@@ -237,8 +237,13 @@ void state_t::select(rectf_t x)
void state_t::command(v2f_t x)
{
+ v2f_t snap;
+
+ snap[0] = std::round(x[0] - 0.5f) + 0.5f;
+ snap[1] = std::round(x[1] - 0.5f) + 0.5f;
+
for (unit_t *unit : selected_units)
- unit->start_moving(x, now);
+ unit->start_moving(snap, now);
}
void state_t::tick(double now_, double dt_)