Implemented Gamequit function
This commit is contained in:
@@ -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 ) {
|
||||
|
||||
@@ -6,7 +6,7 @@ namespace Game {
|
||||
#define WINDOW_WIDTH = 800;
|
||||
#define WINDOW_HEIGHT = 600;
|
||||
|
||||
void exit(int code);
|
||||
void exit();
|
||||
|
||||
}
|
||||
#endif
|
||||
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user