Changeset 1f1eb58 in network-game for client/Client/main.cpp
- Timestamp:
- Jul 14, 2013, 4:11:25 PM (11 years ago)
- Branches:
- master
- Children:
- 5a64bea
- Parents:
- 1a3c42d
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
client/Client/main.cpp
r1a3c42d r1f1eb58 52 52 POSITION screenToMap(POSITION pos); 53 53 POSITION mapToScreen(POSITION pos); 54 int getRefreshRate(int width, int height); 54 55 55 56 // callbacks … … 100 101 string username; 101 102 chat chatConsole; 102 103 103 104 int main(int argc, char **argv) 104 105 { … … 113 114 unsigned int curPlayerId = -1; 114 115 int scoreBlue, scoreRed; 116 bool fullscreen = false; 115 117 116 118 scoreBlue = 0; … … 160 162 } 161 163 162 display = al_create_display(SCREEN_W, SCREEN_H); 164 int refreshRate = getRefreshRate(SCREEN_W, SCREEN_H); 165 // if the computer doesn't support this resolution, just use windowed mode 166 if (refreshRate > 0 && fullscreen) { 167 al_set_new_display_flags(ALLEGRO_FULLSCREEN); 168 al_set_new_display_refresh_rate(refreshRate); 169 } 170 display = al_create_display(SCREEN_W, SCREEN_H); 163 171 if(!display) { 164 172 fprintf(stderr, "failed to create display!\n"); … … 446 454 return 0; 447 455 } 456 457 448 458 449 459 // need to make a function like this that works on windows … … 550 560 551 561 cout << "Got a valid login response with the player" << endl; 552 cout << "Player id: " << curPlayerId << endl; 562 cout << "Player id: " << curPlayerId << endl; 563 cout << "Player health: " << p.health << endl; 553 564 cout << "map size: " << mapPlayers.size() << endl; 554 565 } … … 611 622 case MSG_TYPE_PLAYER: 612 623 { 624 cout << "Received MSG_TYPE_PLAYER" << endl; 625 613 626 Player p("", ""); 614 627 p.deserialize(msg.buffer); … … 620 633 p.isDead = false; 621 634 635 cout << mapPlayers[p.id].pos.x << ", " << mapPlayers[p.id].pos.y << endl; 636 cout << "health:" << mapPlayers[p.id].health << endl; 637 cout << "is dead?:" << mapPlayers[p.id].isDead << endl; 622 638 mapPlayers[p.id] = p; 639 cout << mapPlayers[p.id].pos.x << ", " << mapPlayers[p.id].pos.y << endl; 640 cout << "health:" << mapPlayers[p.id].health << endl; 641 cout << "is dead?:" << mapPlayers[p.id].isDead << endl; 623 642 624 643 break; … … 956 975 sendMessage(&msgTo, sock, &server); 957 976 } 977 978 int getRefreshRate(int width, int height) { 979 int numRefreshRates = al_get_num_display_modes(); 980 ALLEGRO_DISPLAY_MODE displayMode; 981 982 for(int i=0; i<numRefreshRates; i++) { 983 al_get_display_mode(i, &displayMode); 984 985 if (displayMode.width == width && displayMode.height == height) 986 return displayMode.refresh_rate; 987 } 988 989 return 0; 990 }
Note:
See TracChangeset
for help on using the changeset viewer.