diff --git a/src/DesktopLauncher.cpp b/src/DesktopLauncher.cpp index 6438d82..e24146a 100755 --- a/src/DesktopLauncher.cpp +++ b/src/DesktopLauncher.cpp @@ -14,6 +14,7 @@ const int SCREEN_WIDTH = 800; const int SCREEN_HEIGHT = 600; static SDL_Window* gWindow = NULL; static SDL_GLContext glcontext; +static bool gameQuit = false; void dispose(); bool initSDL(); @@ -26,11 +27,10 @@ int main(int argc, char *argv[]) { } //While application is running - bool quit = false; DarkRP2D resA(gWindow); resA.create(); unsigned int lastTime = SDL_GetTicks(), currentTime, elapsedTime; - while( !quit ) { + while( !gameQuit ) { currentTime = SDL_GetTicks(); elapsedTime = currentTime - lastTime; lastTime = currentTime; @@ -41,6 +41,10 @@ int main(int argc, char *argv[]) { return 0; } +void Game::exit() { + gameQuit = true; +} + bool initSDL() { //Init SDL if(SDL_Init(SDL_INIT_VIDEO) < 0 ) { diff --git a/src/DesktopLauncher.h b/src/DesktopLauncher.h index 861fd27..4b92fb9 100644 --- a/src/DesktopLauncher.h +++ b/src/DesktopLauncher.h @@ -6,7 +6,7 @@ namespace Game { #define WINDOW_WIDTH = 800; #define WINDOW_HEIGHT = 600; -void exit(int code); +void exit(); } #endif \ No newline at end of file diff --git a/src/InputHandler.cpp b/src/InputHandler.cpp index 17cb160..0f9bc68 100644 --- a/src/InputHandler.cpp +++ b/src/InputHandler.cpp @@ -1,4 +1,5 @@ #include "InputHandler.h" +#include "Desktoplauncher.h" #include @@ -16,6 +17,7 @@ Command* InputHandler::handleInput(SDL_Event *event) { } switch (event->type) { case SDL_QUIT: + Game::exit(); return NULL; break; case SDL_KEYDOWN: