diff --git a/cpp/Application.cpp b/cpp/Application.cpp index ff9287e..2573ca7 100644 --- a/cpp/Application.cpp +++ b/cpp/Application.cpp @@ -1,10 +1,31 @@ #include "Gedeng/Application.h" +#include "Gedeng/Time.h" +#include "Gedeng/Logger.h" namespace Gedeng { void Application::run() { + unsigned long previous_time_ms = Time::get_time_ms(); + unsigned long time_until_fixed_update_ms = 0.0; + while (true) { - // TODO: Implement + unsigned long current_time_ms = Time::get_time_ms(); + unsigned long elapsed_time_ms = current_time_ms - previous_time_ms; + + previous_time_ms = current_time_ms; + time_until_fixed_update_ms += elapsed_time_ms; + + // Process Input + + // Update fixed time step + while (time_until_fixed_update_ms >= MS_PER_UPDATE) { + // Fixed Update + GG_CORE_INFO("Fixed Update"); + time_until_fixed_update_ms -= MS_PER_UPDATE; + } + + // Variable update + GG_CORE_INFO("Variable Update"); } } diff --git a/include/Gedeng/Application.h b/include/Gedeng/Application.h index ce00f3b..d3f737d 100644 --- a/include/Gedeng/Application.h +++ b/include/Gedeng/Application.h @@ -10,6 +10,9 @@ class Application { virtual ~Application() = default; void run(); + + private: + const unsigned long MS_PER_UPDATE = 20; }; // To be defined in client applications