Changeset 5a5f131 in network-game
- Timestamp:
- Jun 19, 2013, 11:54:55 PM (11 years ago)
- Branches:
- master
- Children:
- 5c95436
- Parents:
- 66c4ec4
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
client/Client/main.cpp
r66c4ec4 r5a5f131 367 367 for (it2 = mapProjectiles.begin(); it2 != mapProjectiles.end(); it2++) 368 368 { 369 cout << "Update projectile position" << endl;370 369 it2->second.move(mapPlayers); 371 370 } … … 377 376 for (it2 = mapProjectiles.begin(); it2 != mapProjectiles.end(); it2++) 378 377 { 379 cout << "Draw projectile" << endl;380 381 378 Projectile proj = it2->second; 382 379 … … 532 529 case MSG_TYPE_PLAYER: // kind of hacky to put this here 533 530 { 534 cout << "Got MSG_TYPE_PLAYER message in STATE_START" << endl;535 536 531 Player p("", ""); 537 532 p.deserialize(msg.buffer); 538 533 p.timeLastUpdated = getCurrentMillis(); 534 539 535 mapPlayers[p.id] = p; 540 536 541 cout << "new player id: " << p.id << endl;542 cout << "map size: " << mapPlayers.size() << endl;543 544 537 break; 545 538 } 546 539 case MSG_TYPE_OBJECT: 547 540 { 548 cout << "Received OBJECT message in STATE_START." << endl;549 550 541 WorldMap::Object o(0, WorldMap::OBJECT_NONE, 0, 0); 551 542 o.deserialize(msg.buffer); … … 591 582 case MSG_TYPE_PLAYER: 592 583 { 593 //cout << "Got MSG_TYPE_PLAYER message in STATE_LOGIN" << endl;594 595 584 Player p("", ""); 596 585 p.deserialize(msg.buffer); 597 586 p.timeLastUpdated = getCurrentMillis(); 598 587 p.isChasing = false; 588 if (p.health <= 0) 589 p.isDead = true; 590 else 591 p.isDead = false; 592 599 593 mapPlayers[p.id] = p; 600 594 … … 603 597 case MSG_TYPE_PLAYER_MOVE: 604 598 { 605 cout << "Got a player move message" << endl;606 607 599 unsigned int id; 608 600 int x, y; … … 793 785 { 794 786 p = &it->second; 787 788 if (p->isDead) 789 continue; 790 795 791 pos = mapToScreen(p->pos); 796 792 -
common/Projectile.cpp
r66c4ec4 r5a5f131 74 74 // if the current target logs off, this method will run into problems 75 75 76 cout << "Inside projectile move" << endl;77 78 76 unsigned long long curTime = getCurrentMillis(); 79 cout << "Got current time" << endl;80 77 81 78 Player targetP = mapPlayers[target]; 82 cout << "Got target" << endl;83 79 84 80 if (timeLastUpdated == 0) { … … 92 88 float dist = sqrt(pow(targetP.pos.x-pos.x, 2) + pow(targetP.pos.y-pos.y, 2)); 93 89 94 cout << "About to finish projectile move" << endl;95 96 90 if (dist <= pixels) { 97 91 pos.x = targetP.pos.x;
Note:
See TracChangeset
for help on using the changeset viewer.