summaryrefslogtreecommitdiff
path: root/src/game
diff options
context:
space:
mode:
authorPaweł Redman <pawel.redman@gmail.com>2018-04-14 15:40:24 +0200
committerPaweł Redman <pawel.redman@gmail.com>2018-04-14 15:41:05 +0200
commite132c6a9f75918978051e8eb23092f5d05c7c3fc (patch)
treed20a022b4991749d2a2d3bad4ebb752fbd059861 /src/game
parentbae14803b28c4e9641d0e2e7462fdc1e7405c0aa (diff)
Redo frequency counters.
Diffstat (limited to 'src/game')
-rw-r--r--src/game/game.cpp12
-rw-r--r--src/game/interface.cpp2
2 files changed, 11 insertions, 3 deletions
diff --git a/src/game/game.cpp b/src/game/game.cpp
index bc8d3c7..185e2d1 100644
--- a/src/game/game.cpp
+++ b/src/game/game.cpp
@@ -307,7 +307,7 @@ void state_t::resume(void)
}
#define TIME_DELTA ((ntime_t)1000000000 / 100)
-#define TIME_LIMIT ((ntime_t)1000000000 / 10)
+#define TIME_LIMIT ((ntime_t)1000000000 / 20)
void state_t::tick(ntime_t time_)
{
@@ -344,7 +344,15 @@ void state_t::tick(ntime_t time_)
fc_game.tick();
if (nclock() - time_ > TIME_LIMIT) {
- frames_behind += target - frames_since_t0;
+ size_t left;
+
+ left = target - frames_since_t0;
+ t0 = nclock();
+ frames_since_t0 = 0;
+ frames_behind++;
+
+ interface->print("(Lag: " + std::to_string(left) + ")");
+
break;
}
}
diff --git a/src/game/interface.cpp b/src/game/interface.cpp
index 5b2d7b8..5872d17 100644
--- a/src/game/interface.cpp
+++ b/src/game/interface.cpp
@@ -381,7 +381,7 @@ void state_t::render_to(render::state_t *render)
x[1] -= em;
ss.str(std::string());
ss << std::fixed << std::setprecision(1);
- ss << "FPS: " << fc_render.freq_ma() << ", " << fc_game.freq_ma() << " Hz";
+ ss << "FPS: " << fc_render.read(SEC(1)) << ", " << fc_game.read(SEC(1)) << " Hz";
render->render_text(x, em, ss.str(), render::ALIGN_LEFT_TOP, sf::Color::White);
x[1] -= em;