From baf1a05e0a6b46ca4311361fbc4579e6679f84c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakob=20H=C3=B6rdt?= <6329417-neop_@users.noreply.gitlab.com> Date: Sun, 4 Aug 2024 14:57:29 +0200 Subject: [PATCH] revert misguided batchsize adaption just set how many steps to do each frame --- main.cpp | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/main.cpp b/main.cpp index 1835dce..ba45d45 100644 --- a/main.cpp +++ b/main.cpp @@ -101,6 +101,7 @@ int main() { // aarrggbb?? constexpr Uint32 bg_color = 0xffdbd7c0; constexpr Uint32 walk_color = 0xff0d0f14; + constexpr auto batchsize = 1000; SDL_LockSurface(window_surface); for (int i = 0; i < window_surface->w * window_surface->h; ++i) { @@ -108,13 +109,11 @@ int main() { } SDL_UnlockSurface(window_surface); - auto batchsize = 100.0; - constexpr auto frametime_target = std::chrono::milliseconds{10}; const auto start_time = clock::now(); auto next_poll_events_time = start_time; - auto frame_start = start_time - frametime_target; - clock::duration frame_time = frametime_target; + auto frame_start = start_time; + clock::duration frame_time; for (bool continu = true; continu;) { { // measure frame_time @@ -123,10 +122,8 @@ int main() { frame_start = now; } - batchsize = batchsize * (0.9 + 0.1 * frametime_target / frame_time); - SDL_LockSurface(window_surface); - for (auto step = 0z; step < int(batchsize); ++step) { + for (auto step = 0z; step < batchsize; ++step) { SDL_Point newpoint; do { newpoint = pos + directions[dist(rne)];