Changeset 03ba5e3 in network-game


Ignore:
Timestamp:
Sep 27, 2013, 7:31:17 PM (11 years ago)
Author:
Dmitry Portnoy <dportnoy@…>
Branches:
master
Children:
ab8fd40
Parents:
a6fe73d
Message:

Added a NEW_GAME screen with a button to leave the game and return to the lobby

File:
1 edited

Legend:

Unmodified
Added
Removed
  • client/Client/main.cpp

    ra6fe73d r03ba5e3  
    7070void joinGame();
    7171void createGame();
     72void leaveGame();
    7273
    7374void error(const char *);
     
    9293Window* wndLobby;
    9394Window* wndGame;
     95Window* wndNewGame;
    9496Window* wndGameDebug;
    9597Window* wndCurrent;
     
    280282   cout << "Created game screen" << endl;
    281283
     284   wndNewGame = new Window(0, 0, SCREEN_W, SCREEN_H);
     285   wndNewGame->addComponent(new Button(880, 10, 120, 20, font, "Leave Game", leaveGame));
     286
     287   cout << "Created new game screen" << endl;
     288
    282289   goToLoginScreen();
    283290 
     
    467474            }
    468475         }
     476         else if (wndCurrent == wndNewGame)
     477         {
     478            ostringstream ossScoreBlue, ossScoreRed;
     479
     480            ossScoreBlue << "Blue: " << game->getBlueScore() << endl;
     481            ossScoreRed << "Red: " << game->getRedScore() << endl;
     482
     483            al_draw_text(font, al_map_rgb(0, 255, 0), 330, 80, ALLEGRO_ALIGN_LEFT, ossScoreBlue.str().c_str());
     484            al_draw_text(font, al_map_rgb(0, 255, 0), 515, 80, ALLEGRO_ALIGN_LEFT, ossScoreRed.str().c_str());
     485         }
    469486         else if (wndCurrent == wndGame)
    470487         {
     
    852869               cout << "Received a JOIN_GAME_SUCCESS message" << endl;
    853870
    854                string gameName(msg.buffer);
    855                
     871               string gameName(msg.buffer);         
     872               game = new Game(gameName, "../../data/map.txt");
    856873               cout << "Game name: " << gameName << endl;
    857                
    858                game = new Game(gameName, "../../data/map.txt");
    859 
    860                /*
     874
    861875               state = STATE_NEW_GAME;
     876               wndCurrent = wndNewGame;
    862877
    863878               msgTo.type = MSG_TYPE_JOIN_GAME_ACK;
     
    865880
    866881               msgProcessor.sendMessage(&msgTo, sock, &server, &outputLog);
    867                */
    868882
    869883               break;
     
    12991313   msgProcessor.sendMessage(&msgTo, sock, &server, &outputLog);
    13001314}
     1315
     1316void leaveGame()
     1317{
     1318   cout << "Leaving game" << endl;
     1319
     1320   game = NULL;
     1321   
     1322   state = STATE_LOBBY;
     1323   wndCurrent = wndLobby;
     1324
     1325   msgTo.type = MSG_TYPE_LEAVE_GAME;
     1326
     1327   msgProcessor.sendMessage(&msgTo, sock, &server, &outputLog);
     1328}
Note: See TracChangeset for help on using the changeset viewer.