- [NEW] game::windowHasFocus
This commit is contained in:
@@ -6,6 +6,8 @@
|
|||||||
|
|
||||||
namespace game
|
namespace game
|
||||||
{
|
{
|
||||||
|
bool windowHasFocus = true;
|
||||||
|
|
||||||
static bool (*loop)() = nullptr;
|
static bool (*loop)() = nullptr;
|
||||||
static unsigned int ticks_per_frame = 1000/60;
|
static unsigned int ticks_per_frame = 1000/60;
|
||||||
static std::map<std::string, int> config;
|
static std::map<std::string, int> config;
|
||||||
@@ -39,6 +41,7 @@ namespace game
|
|||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
|
game::windowHasFocus = true;
|
||||||
game::init();
|
game::init();
|
||||||
input::init(draw::getZoom());
|
input::init(draw::getZoom());
|
||||||
|
|
||||||
@@ -67,6 +70,10 @@ int main(int argc, char *argv[])
|
|||||||
{
|
{
|
||||||
input::updateWheel(e.wheel.y);
|
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)
|
if (SDL_GetTicks()-current_ticks >= game::ticks_per_frame)
|
||||||
|
|||||||
@@ -6,6 +6,8 @@
|
|||||||
#include "jfile.h"
|
#include "jfile.h"
|
||||||
namespace game
|
namespace game
|
||||||
{
|
{
|
||||||
|
extern bool windowHasFocus;
|
||||||
|
|
||||||
void setUpdateTicks(const int ticks);
|
void setUpdateTicks(const int ticks);
|
||||||
|
|
||||||
void init();
|
void init();
|
||||||
|
|||||||
Reference in New Issue
Block a user