Implemented Gamequit function
This commit is contained in:
@@ -14,6 +14,7 @@ const int SCREEN_WIDTH = 800;
|
|||||||
const int SCREEN_HEIGHT = 600;
|
const int SCREEN_HEIGHT = 600;
|
||||||
static SDL_Window* gWindow = NULL;
|
static SDL_Window* gWindow = NULL;
|
||||||
static SDL_GLContext glcontext;
|
static SDL_GLContext glcontext;
|
||||||
|
static bool gameQuit = false;
|
||||||
|
|
||||||
void dispose();
|
void dispose();
|
||||||
bool initSDL();
|
bool initSDL();
|
||||||
@@ -26,11 +27,10 @@ int main(int argc, char *argv[]) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//While application is running
|
//While application is running
|
||||||
bool quit = false;
|
|
||||||
DarkRP2D resA(gWindow);
|
DarkRP2D resA(gWindow);
|
||||||
resA.create();
|
resA.create();
|
||||||
unsigned int lastTime = SDL_GetTicks(), currentTime, elapsedTime;
|
unsigned int lastTime = SDL_GetTicks(), currentTime, elapsedTime;
|
||||||
while( !quit ) {
|
while( !gameQuit ) {
|
||||||
currentTime = SDL_GetTicks();
|
currentTime = SDL_GetTicks();
|
||||||
elapsedTime = currentTime - lastTime;
|
elapsedTime = currentTime - lastTime;
|
||||||
lastTime = currentTime;
|
lastTime = currentTime;
|
||||||
@@ -41,6 +41,10 @@ int main(int argc, char *argv[]) {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Game::exit() {
|
||||||
|
gameQuit = true;
|
||||||
|
}
|
||||||
|
|
||||||
bool initSDL() {
|
bool initSDL() {
|
||||||
//Init SDL
|
//Init SDL
|
||||||
if(SDL_Init(SDL_INIT_VIDEO) < 0 ) {
|
if(SDL_Init(SDL_INIT_VIDEO) < 0 ) {
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ namespace Game {
|
|||||||
#define WINDOW_WIDTH = 800;
|
#define WINDOW_WIDTH = 800;
|
||||||
#define WINDOW_HEIGHT = 600;
|
#define WINDOW_HEIGHT = 600;
|
||||||
|
|
||||||
void exit(int code);
|
void exit();
|
||||||
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
#include "InputHandler.h"
|
#include "InputHandler.h"
|
||||||
|
#include "Desktoplauncher.h"
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
@@ -16,6 +17,7 @@ Command* InputHandler::handleInput(SDL_Event *event) {
|
|||||||
}
|
}
|
||||||
switch (event->type) {
|
switch (event->type) {
|
||||||
case SDL_QUIT:
|
case SDL_QUIT:
|
||||||
|
Game::exit();
|
||||||
return NULL;
|
return NULL;
|
||||||
break;
|
break;
|
||||||
case SDL_KEYDOWN:
|
case SDL_KEYDOWN:
|
||||||
|
|||||||
Reference in New Issue
Block a user