From bf4b3a5c35152c1292757134123b3363d0f81bf6 Mon Sep 17 00:00:00 2001 From: Matt Kosarek Date: Mon, 29 Dec 2025 09:34:00 -0500 Subject: Renamed PascalCase files to snake_case --- themes/src/main_loop.cpp | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 themes/src/main_loop.cpp (limited to 'themes/src/main_loop.cpp') diff --git a/themes/src/main_loop.cpp b/themes/src/main_loop.cpp new file mode 100644 index 0000000..e5397ca --- /dev/null +++ b/themes/src/main_loop.cpp @@ -0,0 +1,31 @@ +#include "main_loop.h" +#include +#include + +EM_BOOL loop(double time, void* loop) { + MainLoop* mainLoop = (MainLoop*) loop; + if (!mainLoop->isRunning) { + return false; + } + + if (mainLoop->lastTime == 0) { + mainLoop->lastTime = time; + return true; + } + + long deltaTime = time - mainLoop->lastTime; + mainLoop->lastTime = time; + mainLoop->elapsedTime += deltaTime; + mainLoop->numFrames++; + float deltaTimeSeconds = static_cast(deltaTime) / 1000.f; + + if (mainLoop->elapsedTime >= 1000.0) { + printf("FPS: %d\n", mainLoop->numFrames); + + mainLoop->elapsedTime = 0.0; + mainLoop->numFrames = 0; + } + + mainLoop->updateFunc(deltaTimeSeconds, NULL); + return true; +} \ No newline at end of file -- cgit v1.2.1