Changeset 1785314 in network-game
- Timestamp:
- Sep 24, 2013, 12:31:56 AM (11 years ago)
- Branches:
- master
- Children:
- b72ed16
- Parents:
- c044a36
- Location:
- client/Client
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
client/Client/Client.vcxproj
rc044a36 r1785314 68 68 <ItemGroup> 69 69 <ClCompile Include="..\..\common\Common.cpp" /> 70 <ClCompile Include="..\..\common\Game.cpp" /> 70 71 <ClCompile Include="..\..\common\MessageContainer.cpp" /> 71 72 <ClCompile Include="..\..\common\MessageProcessor.cpp" /> … … 85 86 <ClInclude Include="..\..\common\Common.h" /> 86 87 <ClInclude Include="..\..\common\Compiler.h" /> 88 <ClInclude Include="..\..\common\Game.h" /> 87 89 <ClInclude Include="..\..\common\MessageContainer.h" /> 88 90 <ClInclude Include="..\..\common\MessageProcessor.h" /> -
client/Client/Client.vcxproj.filters
rc044a36 r1785314 70 70 <Filter>Source Files\common</Filter> 71 71 </ClCompile> 72 <ClCompile Include="..\..\common\Game.cpp"> 73 <Filter>Source Files\common</Filter> 74 </ClCompile> 72 75 </ItemGroup> 73 76 <ItemGroup> … … 114 117 <Filter>Header Files\common</Filter> 115 118 </ClInclude> 119 <ClInclude Include="..\..\common\Game.h"> 120 <Filter>Header Files\common</Filter> 121 </ClInclude> 116 122 </ItemGroup> 117 123 <ItemGroup> -
client/Client/main.cpp
rc044a36 r1785314 76 76 enum STATE { 77 77 STATE_START, 78 STATE_LOGIN // this means you're already logged in 78 STATE_LOBBY, 79 STATE_GAME 79 80 }; 80 81 … … 85 86 Window* wndLogin; 86 87 Window* wndRegister; 87 Window* wndMain; 88 Window* wndMainDebug; 88 Window* wndLobby; 89 Window* wndGame; 90 Window* wndGameDebug; 89 91 Window* wndCurrent; 90 92 … … 100 102 TextLabel* lblRegisterStatus; 101 103 102 // wnd Main104 // wndGame 103 105 Textbox* txtChat; 104 106 … … 238 240 cout << "Created register screen" << endl; 239 241 240 wndMain = new Window(0, 0, SCREEN_W, SCREEN_H); 241 wndMain->addComponent(new Textbox(95, 40, 300, 20, font)); 242 wndMain->addComponent(new Button(95, 70, 60, 20, font, "Send", sendChatMessage)); 243 wndMain->addComponent(new Button(20, 10, 160, 20, font, "Toggle Debugging", toggleDebugging)); 244 wndMain->addComponent(new Button(920, 10, 80, 20, font, "Logout", logout)); 245 246 txtChat = (Textbox*)wndMain->getComponent(0); 247 248 wndMainDebug = new Window(0, 0, SCREEN_W, SCREEN_H); 249 wndMainDebug->addComponent(new Button(20, 10, 160, 20, font, "Toggle Debugging", toggleDebugging)); 250 wndMainDebug->addComponent(new Button(920, 10, 80, 20, font, "Logout", logout)); 251 252 cout << "Created main screen" << endl; 242 wndLobby = new Window(0, 0, SCREEN_W, SCREEN_H); 243 244 cout << "Created lobby screen" << endl; 245 246 wndGame = new Window(0, 0, SCREEN_W, SCREEN_H); 247 wndGame->addComponent(new Textbox(95, 40, 300, 20, font)); 248 wndGame->addComponent(new Button(95, 70, 60, 20, font, "Send", sendChatMessage)); 249 wndGame->addComponent(new Button(20, 10, 160, 20, font, "Toggle Debugging", toggleDebugging)); 250 wndGame->addComponent(new Button(920, 10, 80, 20, font, "Logout", logout)); 251 252 txtChat = (Textbox*)wndGame->getComponent(0); 253 254 wndGameDebug = new Window(0, 0, SCREEN_W, SCREEN_H); 255 wndGameDebug->addComponent(new Button(20, 10, 160, 20, font, "Toggle Debugging", toggleDebugging)); 256 wndGameDebug->addComponent(new Button(920, 10, 80, 20, font, "Logout", logout)); 257 258 cout << "Created game screen" << endl; 253 259 254 260 goToLoginScreen(); … … 319 325 break; 320 326 case ALLEGRO_KEY_S: // pickup an item next to you 321 if (state == STATE_LO GIN) {327 if (state == STATE_LOBBY) { 322 328 msgTo.type = MSG_TYPE_PICKUP_FLAG; 323 329 memcpy(msgTo.buffer, &curPlayerId, 4); … … 326 332 break; 327 333 case ALLEGRO_KEY_D: // drop the current item 328 if (state == STATE_LO GIN) {334 if (state == STATE_LOBBY) { 329 335 // find the current player in the player list 330 336 map<unsigned int, Player>::iterator it; … … 355 361 } 356 362 else if(ev.type == ALLEGRO_EVENT_MOUSE_BUTTON_UP) { 357 if(wndCurrent == wndMain) { 363 if(wndCurrent == wndLobby) { 364 if (ev.mouse.button == 1) { // left click 365 state = STATE_GAME; 366 wndCurrent = wndGame; 367 } 368 }else if(wndCurrent == wndGame) { 358 369 if (ev.mouse.button == 1) { // left click 359 370 msgTo.type = MSG_TYPE_PLAYER_MOVE; … … 414 425 //msgProcessor.cleanAckedMessages(&outputLog); 415 426 416 if (debugging && wndCurrent == wnd Main)417 wnd MainDebug->draw(display);427 if (debugging && wndCurrent == wndGame) 428 wndGameDebug->draw(display); 418 429 else 419 430 wndCurrent->draw(display); 420 431 421 if(wndCurrent == wnd Main) {432 if(wndCurrent == wndGame) { 422 433 if (!debugging) 423 434 chatConsole.draw(font, al_map_rgb(255,255,255)); … … 494 505 495 506 delete wndLogin; 496 delete wndMain; 507 delete wndRegister; 508 delete wndLobby; 509 delete wndGame; 510 delete wndGameDebug; 497 511 498 512 delete gameMap; … … 600 614 break; 601 615 } 602 case STATE_LOGIN: 616 case STATE_LOBBY: 617 case STATE_GAME: 603 618 { 604 619 switch(msg.type) … … 622 637 else 623 638 { 624 wndCurrent = wnd Main;639 wndCurrent = wndLobby; 625 640 626 641 Player p("", ""); … … 689 704 case MSG_TYPE_OBJECT: 690 705 { 691 cout << "Received object message in STATE_LO GIN." << endl;706 cout << "Received object message in STATE_LOBBY." << endl; 692 707 693 708 WorldMap::Object o(0, WorldMap::OBJECT_NONE, 0, 0); … … 779 794 default: 780 795 { 781 cout << "(STATE_LO GIN) Received invlaid message of type " << msg.type << endl;796 cout << "(STATE_LOBBY) Received invlaid message of type " << msg.type << endl; 782 797 break; 783 798 } … … 977 992 msgProcessor.sendMessage(&msgTo, sock, &server, &outputLog); 978 993 979 state = STATE_LO GIN;994 state = STATE_LOBBY; 980 995 } 981 996
Note:
See TracChangeset
for help on using the changeset viewer.