- [NEW] game::windowHasFocus

This commit is contained in:
2023-10-19 18:57:02 +02:00
parent ccb2f3fbca
commit 720c15d03a
2 changed files with 9 additions and 0 deletions

View File

@@ -6,6 +6,8 @@
namespace game
{
bool windowHasFocus = true;
static bool (*loop)() = nullptr;
static unsigned int ticks_per_frame = 1000/60;
static std::map<std::string, int> config;
@@ -39,6 +41,7 @@ namespace game
int main(int argc, char *argv[])
{
game::windowHasFocus = true;
game::init();
input::init(draw::getZoom());
@@ -67,6 +70,10 @@ int main(int argc, char *argv[])
{
input::updateWheel(e.wheel.y);
}
if ( e.type == SDL_WINDOWEVENT ) {
if (e.window.event == SDL_WINDOWEVENT_FOCUS_GAINED) game::windowHasFocus = true;
if (e.window.event == SDL_WINDOWEVENT_FOCUS_LOST) game::windowHasFocus = false;
}
}
if (SDL_GetTicks()-current_ticks >= game::ticks_per_frame)

View File

@@ -6,6 +6,8 @@
#include "jfile.h"
namespace game
{
extern bool windowHasFocus;
void setUpdateTicks(const int ticks);
void init();