summaryrefslogtreecommitdiff
path: root/src/game.cpp
diff options
context:
space:
mode:
authorPaweł Redman <pawel.redman@gmail.com>2017-11-08 12:26:43 +0100
committerPaweł Redman <pawel.redman@gmail.com>2017-11-08 12:26:43 +0100
commitcdd75000effac0216588766234cfa5b3e8e304d5 (patch)
tree3832063bf12dae9e8b29c9e787d08dc75a9ba704 /src/game.cpp
parentc5a621b3ebeb180d2181df35038ed856714b64e2 (diff)
Frametime-independent dynamics.
Diffstat (limited to 'src/game.cpp')
-rw-r--r--src/game.cpp9
1 files changed, 5 insertions, 4 deletions
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