- Timestamp:
- Jun 9, 2013, 7:29:59 PM (12 years ago)
- Branches:
- master
- Children:
- 11d21ee
- Parents:
- 8795a38
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
client/Client/main.cpp
r8795a38 r8c74150 13 13 #endif 14 14 15 #include <sys/types.h>16 15 #include <cstdio> 17 16 #include <cstdlib> 17 #include <cmath> 18 #include <sys/types.h> 18 19 #include <string> 19 20 #include <iostream> 20 21 #include <sstream> 21 22 #include <map>23 24 22 #include <map> 25 23 … … 360 358 } 361 359 360 // update projectile positions 361 map<unsigned int, Projectile>::iterator it2; 362 for (it2 = mapProjectiles.begin(); it2 != mapProjectiles.end(); it2++) 363 { 364 cout << "Update projectile position" << endl; 365 it2->second.move(mapPlayers); 366 } 367 362 368 drawMap(gameMap); 363 369 drawPlayers(mapPlayers, font, curPlayerId); 370 371 // draw projectiles 372 for (it2 = mapProjectiles.begin(); it2 != mapProjectiles.end(); it2++) 373 { 374 cout << "Draw projectile" << endl; 375 376 Projectile proj = it2->second; 377 378 FLOAT_POSITION target = mapPlayers[proj.target].pos; 379 float angle = atan2(target.y-proj.pos.toFloat().y, target.x-proj.pos.toFloat().x); 380 381 POSITION start, end; 382 start.x = cos(angle)*15+proj.pos.x; 383 start.y = sin(angle)*15+proj.pos.y; 384 end.x = proj.pos.x; 385 end.y = proj.pos.y; 386 387 start = mapToScreen(start); 388 end = mapToScreen(end); 389 390 al_draw_line(start.x, start.y, end.x, end.y, al_map_rgb(0, 0, 0), 4); 391 } 364 392 } 365 393 … … 628 656 case MSG_TYPE_PROJECTILE: 629 657 { 630 cout << "Received a prjectilemessage" << endl;658 cout << "Received a PROJECTILE message" << endl; 631 659 632 660 int id, x, y, targetId; … … 637 665 memcpy(&targetId, msg.buffer+12, 4); 638 666 639 cout << "id" << id << endl; 640 cout << "x" << x << endl; 641 cout << "y" << y << endl; 642 cout << "Target" << targetId << endl; 667 cout << "id: " << id << endl; 668 cout << "x: " << x << endl; 669 cout << "y: " << y << endl; 670 cout << "Target: " << targetId << endl; 671 672 Projectile proj(x, y, targetId, 0); 673 proj.setId(id); 674 675 mapProjectiles[id] = proj; 643 676 644 677 break; … … 646 679 case MSG_TYPE_REMOVE_PROJECTILE: 647 680 { 681 cout << "Received a REMOVE_PROJECTILE message" << endl; 682 683 int id; 684 685 memcpy(&id, msg.buffer, 4); 686 687 mapProjectiles.erase(id); 688 648 689 break; 649 690 }
Note:
See TracChangeset
for help on using the changeset viewer.