Changeset 102


Ignore:
Timestamp:
Aug 11, 2010, 6:18:42 PM (10 years ago)
Author:
sam
Message:

Implement a quit() mechanism in the Game class.

Location:
trunk/src
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/game.cpp

    r100 r102  
    2727    int x, y;
    2828    int mousex, mousey;
     29    int done;
    2930
    3031    int frame;
     
    4142    data->font = new Font("gfx/font/ascii.png");
    4243    data->x = data->y = 0;
     44    data->done = 0;
    4345    data->frame = 0;
    4446}
     
    7173}
    7274
     75void Game::Quit()
     76{
     77    data->done = 1;
     78}
     79
     80int Game::Finished()
     81{
     82    return data->done;
     83}
     84
  • trunk/src/game.h

    r100 r102  
    2222    void SetMouse(int x, int y);
    2323    void Render();
     24    void Quit();
     25    int Finished();
    2426
    2527private:
  • trunk/src/test-map.cpp

    r100 r102  
    2222    Game *game = new Game("maps/testmap.tmx");
    2323
    24     for (int done = 0; !done; )
     24    while (!game->Finished())
    2525    {
    2626        /* Test stuff */
     
    4141        {
    4242            if (event.type == SDL_QUIT)
    43                 done = 1;
     43                game->Quit();
    4444            if (event.type == SDL_KEYDOWN)
    4545            {
     
    4747                    video->FullScreen();
    4848                else if (event.key.keysym.sym == SDLK_ESCAPE)
    49                     done = 1;
     49                    game->Quit();
    5050            }
    5151        }
Note: See TracChangeset for help on using the changeset viewer.