mirror of
https://github.com/NoelFB/blah.git
synced 2025-02-18 12:48:27 +08:00
app properly pauses during Time::pause_timer
This commit is contained in:
parent
b939391334
commit
fbc6d894f4
@ -123,20 +123,26 @@ bool App::run(const Config* c)
|
|||||||
{
|
{
|
||||||
time_accumulator -= time_target;
|
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::milliseconds += time_target;
|
||||||
Time::delta = 1.0f / app_config.target_framerate;
|
|
||||||
Time::previous_elapsed = Time::elapsed;
|
Time::previous_elapsed = Time::elapsed;
|
||||||
Time::elapsed += Time::delta;
|
Time::elapsed += Time::delta;
|
||||||
|
|
||||||
Internal::Input::frame();
|
Internal::Input::frame();
|
||||||
Internal::Graphics::frame();
|
Internal::Graphics::frame();
|
||||||
|
|
||||||
Time::pause_timer -= Time::delta;
|
if (app_config.on_update != nullptr)
|
||||||
if (Time::pause_timer <= 0)
|
app_config.on_update();
|
||||||
{
|
|
||||||
if (app_config.on_update != nullptr)
|
|
||||||
app_config.on_update();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -7,10 +7,10 @@ using namespace Blah;
|
|||||||
|
|
||||||
void Log::print(const char* format, ...)
|
void Log::print(const char* format, ...)
|
||||||
{
|
{
|
||||||
char msg[BLAH_MAX_MESSAGE];
|
char msg[BLAH_MESSAGE];
|
||||||
va_list ap;
|
va_list ap;
|
||||||
va_start(ap, format);
|
va_start(ap, format);
|
||||||
vsnprintf(msg, sizeof(char) * BLAH_MAX_MESSAGE, format, ap);
|
vsnprintf(msg, sizeof(char) * BLAH_MESSAGE, format, ap);
|
||||||
va_end(ap);
|
va_end(ap);
|
||||||
|
|
||||||
if (App::is_running() && App::config()->on_info != nullptr)
|
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, ...)
|
void Log::warn(const char* format, ...)
|
||||||
{
|
{
|
||||||
char msg[BLAH_MAX_MESSAGE];
|
char msg[BLAH_MESSAGE];
|
||||||
va_list ap;
|
va_list ap;
|
||||||
va_start(ap, format);
|
va_start(ap, format);
|
||||||
vsnprintf(msg, sizeof(char) * BLAH_MAX_MESSAGE, format, ap);
|
vsnprintf(msg, sizeof(char) * BLAH_MESSAGE, format, ap);
|
||||||
va_end(ap);
|
va_end(ap);
|
||||||
|
|
||||||
if (App::is_running() && App::config()->on_warn != nullptr)
|
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, ...)
|
void Log::error(const char* format, ...)
|
||||||
{
|
{
|
||||||
char msg[BLAH_MAX_MESSAGE];
|
char msg[BLAH_MESSAGE];
|
||||||
va_list ap;
|
va_list ap;
|
||||||
va_start(ap, format);
|
va_start(ap, format);
|
||||||
vsnprintf(msg, sizeof(char) * BLAH_MAX_MESSAGE, format, ap);
|
vsnprintf(msg, sizeof(char) * BLAH_MESSAGE, format, ap);
|
||||||
va_end(ap);
|
va_end(ap);
|
||||||
|
|
||||||
if (App::is_running() && App::config()->on_error != nullptr)
|
if (App::is_running() && App::config()->on_error != nullptr)
|
||||||
|
Loading…
Reference in New Issue
Block a user