From cdd75000effac0216588766234cfa5b3e8e304d5 Mon Sep 17 00:00:00 2001 From: Paweł Redman Date: Wed, 8 Nov 2017 12:26:43 +0100 Subject: Frametime-independent dynamics. --- src/game.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'src/game.cpp') diff --git a/src/game.cpp b/src/game.cpp index bfc698d..a3af9ed 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -73,7 +73,7 @@ public: link(world); } - void keep_moving(double now) + void keep_moving(double now, double dt) { float time; @@ -83,7 +83,7 @@ public: if (move.blocked && now < move.next_attempt) return; - time = 0.15; // FIXME + time = dt * 10; while (time > 0.0f) { v2f_t delta, next, x_new; @@ -241,12 +241,13 @@ void state_t::command(v2f_t x) unit->start_moving(x, now); } -void state_t::tick(double now_) +void state_t::tick(double now_, double dt_) { now = now_; + dt = dt_; for (unit_t *unit : units) - unit->keep_moving(now); + unit->keep_moving(now, dt); } } //namespace game -- cgit