diff --git a/src/game.cpp b/src/game.cpp index ab009274..be2da0f4 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -26,6 +26,7 @@ private: Font *font; int x, y; int mousex, mousey; + int done; int frame; }; @@ -40,6 +41,7 @@ Game::Game(char const *mapname) data->map = new Map(mapname); data->font = new Font("gfx/font/ascii.png"); data->x = data->y = 0; + data->done = 0; data->frame = 0; } @@ -70,3 +72,13 @@ void Game::Render() data->font->Print(10, 10, buf); } +void Game::Quit() +{ + data->done = 1; +} + +int Game::Finished() +{ + return data->done; +} + diff --git a/src/game.h b/src/game.h index e01f9853..e28189a4 100644 --- a/src/game.h +++ b/src/game.h @@ -21,6 +21,8 @@ public: void SetMouse(int x, int y); void Render(); + void Quit(); + int Finished(); private: GameData *data; diff --git a/src/test-map.cpp b/src/test-map.cpp index e30e660c..c39a9991 100644 --- a/src/test-map.cpp +++ b/src/test-map.cpp @@ -21,7 +21,7 @@ int main(int argc, char **argv) Video *video = new SdlVideo("Deus Hax", 640, 480); Game *game = new Game("maps/testmap.tmx"); - for (int done = 0; !done; ) + while (!game->Finished()) { /* Test stuff */ int mx, my; @@ -40,13 +40,13 @@ int main(int argc, char **argv) while (SDL_PollEvent(&event)) { if (event.type == SDL_QUIT) - done = 1; + game->Quit(); if (event.type == SDL_KEYDOWN) { if (event.key.keysym.sym == SDLK_RETURN) video->FullScreen(); else if (event.key.keysym.sym == SDLK_ESCAPE) - done = 1; + game->Quit(); } } }