Changeset 4c00935 in network-game


Ignore:
Timestamp:
Jul 19, 2014, 12:35:29 AM (10 years ago)
Author:
dportnoy <dmp1488@…>
Branches:
master
Children:
81c4e8a
Parents:
53643ca
Message:

Client draws real player info and game history on the profile screen and uses player ids from the db instead of generating a new one for each new player sent by the server

File:
1 edited

Legend:

Unmodified
Added
Removed
  • client/Client/main.cpp

    r53643ca r4c00935  
    142142Player* currentPlayer;
    143143
    144 int honorPoints;
    145 int numGames;
     144int honorPoints, wins, losses, numGames;
    146145int** gameHistory;
    147146
     
    166165
    167166   honorPoints = 0;
     167   wins = 0;
     168   losses = 0;
    168169   numGames = 0;
    169170   gameHistory = NULL;
     
    450451            oss.str("");
    451452
     453            oss << "Wins: " << wins << endl;
     454            al_draw_text(font, al_map_rgb(0, 255, 0), 65, 105, ALLEGRO_ALIGN_LEFT, oss.str().c_str());
     455            oss.clear();
     456            oss.str("");
     457
     458            oss << "Loses: " << losses << endl;
     459            al_draw_text(font, al_map_rgb(0, 255, 0), 65, 120, ALLEGRO_ALIGN_LEFT, oss.str().c_str());
     460            oss.clear();
     461            oss.str("");
     462
    452463            // display records of the last 10 games
    453464            for (int i=0; i<numGames; i++) {
     
    458469                  oss << "VICTORY" << endl;
    459470
    460                al_draw_text(font, al_map_rgb(0, 255, 0), 142, 160+30*(i+1), ALLEGRO_ALIGN_CENTRE, oss.str().c_str());
     471               al_draw_text(font, al_map_rgb(0, 255, 0), 142, 190+30*(i+1), ALLEGRO_ALIGN_CENTRE, oss.str().c_str());
    461472               oss.clear();
    462473               oss.str("");
    463474
    464475               oss << gameHistory[i][2] << endl;
    465                al_draw_text(font, al_map_rgb(0, 255, 0), 302, 160+30*(i+1), ALLEGRO_ALIGN_CENTRE, oss.str().c_str());
     476               al_draw_text(font, al_map_rgb(0, 255, 0), 302, 190+30*(i+1), ALLEGRO_ALIGN_CENTRE, oss.str().c_str());
    466477               oss.clear();
    467478               oss.str("");
    468479
    469480               oss << gameHistory[i][3] << endl;
    470                al_draw_text(font, al_map_rgb(0, 255, 0), 462, 160+30*(i+1), ALLEGRO_ALIGN_CENTRE, oss.str().c_str());
     481               al_draw_text(font, al_map_rgb(0, 255, 0), 462, 190+30*(i+1), ALLEGRO_ALIGN_CENTRE, oss.str().c_str());
    471482               oss.clear();
    472483               oss.str("");
    473484
    474485               oss << "6/11/2014, 5:12 PM" << endl;
    475                al_draw_text(font, al_map_rgb(0, 255, 0), 622, 160+30*(i+1), ALLEGRO_ALIGN_CENTRE, oss.str().c_str());
     486               al_draw_text(font, al_map_rgb(0, 255, 0), 622, 190+30*(i+1), ALLEGRO_ALIGN_CENTRE, oss.str().c_str());
    476487               oss.clear();
    477488               oss.str("");
     
    758769   wndProfile = new Window(0, 0, SCREEN_W, SCREEN_H);
    759770   vctComponents.push_back(wndProfile->addComponent(new TextLabel(450, 40, 124, 20, font, "Profile", ALLEGRO_ALIGN_CENTRE)));
    760    vctComponents.push_back(wndProfile->addComponent(new TextLabel(160, 120, 124, 20, font, "Game History", ALLEGRO_ALIGN_CENTRE)));
    761    vctComponents.push_back(wndProfile->addComponent(new TextLabel(600, 160, 124, 20, font, "Time", ALLEGRO_ALIGN_CENTRE)));
    762    vctComponents.push_back(wndProfile->addComponent(new TextLabel(80, 160, 124, 20, font, "Result", ALLEGRO_ALIGN_CENTRE)));
    763    vctComponents.push_back(wndProfile->addComponent(new TextLabel(240, 160, 124, 20, font, "Blue Score", ALLEGRO_ALIGN_CENTRE)));
    764    vctComponents.push_back(wndProfile->addComponent(new TextLabel(400, 160, 124, 20, font, "Red Score", ALLEGRO_ALIGN_CENTRE)));
    765    vctComponents.push_back(wndProfile->addComponent(new TextLabel(560, 160, 124, 20, font, "Time", ALLEGRO_ALIGN_CENTRE)));
     771   vctComponents.push_back(wndProfile->addComponent(new TextLabel(160, 150, 124, 20, font, "Game History", ALLEGRO_ALIGN_CENTRE)));
     772   vctComponents.push_back(wndProfile->addComponent(new TextLabel(600, 190, 124, 20, font, "Time", ALLEGRO_ALIGN_CENTRE)));
     773   vctComponents.push_back(wndProfile->addComponent(new TextLabel(80, 190, 124, 20, font, "Result", ALLEGRO_ALIGN_CENTRE)));
     774   vctComponents.push_back(wndProfile->addComponent(new TextLabel(240, 190, 124, 20, font, "Blue Score", ALLEGRO_ALIGN_CENTRE)));
     775   vctComponents.push_back(wndProfile->addComponent(new TextLabel(400, 190, 124, 20, font, "Red Score", ALLEGRO_ALIGN_CENTRE)));
     776   vctComponents.push_back(wndProfile->addComponent(new TextLabel(560, 190, 124, 20, font, "Time", ALLEGRO_ALIGN_CENTRE)));
    766777   vctComponents.push_back(wndProfile->addComponent(new Button(920, 738, 80, 20, font, "Back", goToLobbyScreen)));
    767778
     
    903914            {
    904915               memcpy(&honorPoints, msg.buffer, 4);
    905                memcpy(&numGames, msg.buffer+4, 4);
     916               memcpy(&wins, msg.buffer+4, 4);
     917               memcpy(&losses, msg.buffer+8, 4);
     918               memcpy(&numGames, msg.buffer+12, 4);
    906919
    907920               cout << "Got records for " << numGames << " games." << endl;
     
    911924                  cout << endl << "game record " << (i+1) << endl;
    912925
    913                   memcpy(&gameHistory[i][0], msg.buffer+8+i*16, 4);
    914                   memcpy(&gameHistory[i][1], msg.buffer+12+i*16, 4);
    915                   memcpy(&gameHistory[i][2], msg.buffer+16+i*16, 4);
    916                   memcpy(&gameHistory[i][3], msg.buffer+20+i*16, 4);
     926                  memcpy(&gameHistory[i][0], msg.buffer+16+i*16, 4);
     927                  memcpy(&gameHistory[i][1], msg.buffer+20+i*16, 4);
     928                  memcpy(&gameHistory[i][2], msg.buffer+24+i*16, 4);
     929                  memcpy(&gameHistory[i][3], msg.buffer+28+i*16, 4);
    917930
    918931                  cout << "result: " << gameHistory[i][0] << endl;
     
    14601473   msgTo.type = MSG_TYPE_PROFILE;
    14611474
     1475   unsigned int playerId = currentPlayer->getId();
     1476   memcpy(msgTo.buffer, &playerId, 4);
    14621477   msgProcessor.sendMessage(&msgTo, &server);
    14631478}
Note: See TracChangeset for help on using the changeset viewer.