summaryrefslogtreecommitdiff
path: root/src/game
diff options
context:
space:
mode:
Diffstat (limited to 'src/game')
-rw-r--r--src/game/game.cpp14
-rw-r--r--src/game/interface.cpp11
2 files changed, 8 insertions, 17 deletions
diff --git a/src/game/game.cpp b/src/game/game.cpp
index 2a944af..4cac4eb 100644
--- a/src/game/game.cpp
+++ b/src/game/game.cpp
@@ -288,11 +288,12 @@ void state_t::resume(void)
paused = false;
}
-#define TIME_DELTA ((ntime_t)1000000000 / 60)
+#define TIME_DELTA ((ntime_t)1000000000 / 100)
+#define TIME_LIMIT ((ntime_t)1000000000 / 10)
void state_t::tick(ntime_t time_)
{
- size_t target, frames_this_tick = 0;
+ size_t target;
if (paused)
return;
@@ -315,13 +316,12 @@ void state_t::tick(ntime_t time_)
frames++;
frames_since_t0++;
- frames_this_tick++;
time += TIME_DELTA;
- if (frames_this_tick == 3) {
- t0 = time_;
- frames_since_t0 = 0;
- frames_behind++;
+ fc_game.tick();
+
+ if (nclock() - time_ > TIME_LIMIT) {
+ frames_behind += target - frames_since_t0;
break;
}
}
diff --git a/src/game/interface.cpp b/src/game/interface.cpp
index b187d42..c6d5e19 100644
--- a/src/game/interface.cpp
+++ b/src/game/interface.cpp
@@ -332,7 +332,6 @@ void state_t::render_to(render::state_t *render)
size_t w = window->getSize().x, h = window->getSize().y;
v2f_t x;
std::stringstream ss;
- double fps;
if (select.selecting) {
sf::Color color;
@@ -391,18 +390,10 @@ void state_t::render_to(render::state_t *render)
ss << render->stats.entities;
render->render_text(x, em, ss.str(), render::ALIGN_LEFT_TOP, sf::Color::White);
- perf_hist_index = (perf_hist_index + 1) % COUNT(perf_hist);
- perf_hist[perf_hist_index] = 1.0 / render->dt;
-
- fps = 0.0;
- for (size_t i = 0; i < COUNT(perf_hist); i++)
- fps += perf_hist[i];
- fps /= COUNT(perf_hist);
-
x[1] += em;
ss.str(std::string());
ss << std::fixed << std::setprecision(1);
- ss << "FPS: " << fps;
+ ss << "FPS: " << fc_render.freq_ma() << ", " << fc_game.freq_ma() << " Hz";
render->render_text(x, em, ss.str(), render::ALIGN_LEFT_TOP, sf::Color::White);
x[1] += em;