- [NEW] game::windowHasFocus
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -6,6 +6,8 @@
|
||||
#include "jfile.h"
|
||||
namespace game
|
||||
{
|
||||
extern bool windowHasFocus;
|
||||
|
||||
void setUpdateTicks(const int ticks);
|
||||
|
||||
void init();
|
||||
|
||||
Reference in New Issue
Block a user