Implemented Gamequit function

This commit is contained in:
Julian Nießner
2018-05-07 17:14:29 +02:00
parent 735f775d89
commit d9eb21a3e8
3 changed files with 9 additions and 3 deletions

View File

@@ -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 ) {

View File

@@ -6,7 +6,7 @@ namespace Game {
#define WINDOW_WIDTH = 800;
#define WINDOW_HEIGHT = 600;
void exit(int code);
void exit();
}
#endif

View File

@@ -1,4 +1,5 @@
#include "InputHandler.h"
#include "Desktoplauncher.h"
#include <iostream>
@@ -16,6 +17,7 @@ Command* InputHandler::handleInput(SDL_Event *event) {
}
switch (event->type) {
case SDL_QUIT:
Game::exit();
return NULL;
break;
case SDL_KEYDOWN: