app properly pauses during Time::pause_timer

This commit is contained in:
Noel Berry 2020-08-27 19:44:03 -07:00
parent b939391334
commit fbc6d894f4
2 changed files with 19 additions and 13 deletions

View File

@ -123,20 +123,26 @@ bool App::run(const Config* c)
{
time_accumulator -= time_target;
Time::delta = (1.0f / app_config.target_framerate);
if (Time::pause_timer > 0)
{
Time::pause_timer -= Time::delta;
if (Time::pause_timer <= -0.0001f)
Time::delta = -Time::pause_timer;
else
continue;
}
Time::milliseconds += time_target;
Time::delta = 1.0f / app_config.target_framerate;
Time::previous_elapsed = Time::elapsed;
Time::elapsed += Time::delta;
Internal::Input::frame();
Internal::Graphics::frame();
Time::pause_timer -= Time::delta;
if (Time::pause_timer <= 0)
{
if (app_config.on_update != nullptr)
app_config.on_update();
}
if (app_config.on_update != nullptr)
app_config.on_update();
}
}

View File

@ -7,10 +7,10 @@ using namespace Blah;
void Log::print(const char* format, ...)
{
char msg[BLAH_MAX_MESSAGE];
char msg[BLAH_MESSAGE];
va_list ap;
va_start(ap, format);
vsnprintf(msg, sizeof(char) * BLAH_MAX_MESSAGE, format, ap);
vsnprintf(msg, sizeof(char) * BLAH_MESSAGE, format, ap);
va_end(ap);
if (App::is_running() && App::config()->on_info != nullptr)
@ -25,10 +25,10 @@ void Log::print(const char* format, ...)
void Log::warn(const char* format, ...)
{
char msg[BLAH_MAX_MESSAGE];
char msg[BLAH_MESSAGE];
va_list ap;
va_start(ap, format);
vsnprintf(msg, sizeof(char) * BLAH_MAX_MESSAGE, format, ap);
vsnprintf(msg, sizeof(char) * BLAH_MESSAGE, format, ap);
va_end(ap);
if (App::is_running() && App::config()->on_warn != nullptr)
@ -43,10 +43,10 @@ void Log::warn(const char* format, ...)
void Log::error(const char* format, ...)
{
char msg[BLAH_MAX_MESSAGE];
char msg[BLAH_MESSAGE];
va_list ap;
va_start(ap, format);
vsnprintf(msg, sizeof(char) * BLAH_MAX_MESSAGE, format, ap);
vsnprintf(msg, sizeof(char) * BLAH_MESSAGE, format, ap);
va_end(ap);
if (App::is_running() && App::config()->on_error != nullptr)