Changeset 5a5f131 in network-game


Ignore:
Timestamp:
Jun 19, 2013, 11:54:55 PM (11 years ago)
Author:
dportnoy <dmp1488@…>
Branches:
master
Children:
5c95436
Parents:
66c4ec4
Message:

Dead players aren't drawn

Files:
2 edited

Legend:

Unmodified
Added
Removed
  • client/Client/main.cpp

    r66c4ec4 r5a5f131  
    367367            for (it2 = mapProjectiles.begin(); it2 != mapProjectiles.end(); it2++)
    368368            {
    369                cout << "Update projectile position" << endl;
    370369               it2->second.move(mapPlayers);
    371370            }
     
    377376            for (it2 = mapProjectiles.begin(); it2 != mapProjectiles.end(); it2++)
    378377            {
    379                cout << "Draw projectile" << endl;
    380 
    381378               Projectile proj = it2->second;
    382379
     
    532529            case MSG_TYPE_PLAYER:   // kind of hacky to put this here
    533530            {
    534                cout << "Got MSG_TYPE_PLAYER message in STATE_START" << endl;
    535 
    536531               Player p("", "");
    537532               p.deserialize(msg.buffer);
    538533               p.timeLastUpdated = getCurrentMillis();
     534
    539535               mapPlayers[p.id] = p;
    540536
    541                cout << "new player id: " << p.id << endl;
    542                cout << "map size: " << mapPlayers.size() << endl;
    543 
    544537               break;
    545538            }
    546539            case MSG_TYPE_OBJECT:
    547540            {
    548                cout << "Received OBJECT message in STATE_START." << endl;
    549 
    550541               WorldMap::Object o(0, WorldMap::OBJECT_NONE, 0, 0);
    551542               o.deserialize(msg.buffer);
     
    591582            case MSG_TYPE_PLAYER:
    592583            {
    593                //cout << "Got MSG_TYPE_PLAYER message in STATE_LOGIN" << endl;
    594 
    595584               Player p("", "");
    596585               p.deserialize(msg.buffer);
    597586               p.timeLastUpdated = getCurrentMillis();
    598587               p.isChasing = false;
     588               if (p.health <= 0)
     589                  p.isDead = true;
     590               else
     591                  p.isDead = false;
     592
    599593               mapPlayers[p.id] = p;
    600594
     
    603597            case MSG_TYPE_PLAYER_MOVE:
    604598            {
    605                cout << "Got a player move message" << endl;
    606 
    607599               unsigned int id;
    608600               int x, y;
     
    793785   {
    794786      p = &it->second;
     787
     788      if (p->isDead)
     789         continue;
     790
    795791      pos = mapToScreen(p->pos);
    796792
  • common/Projectile.cpp

    r66c4ec4 r5a5f131  
    7474   // if the current target logs off, this method will run into problems
    7575
    76    cout << "Inside projectile move" << endl;
    77 
    7876   unsigned long long curTime = getCurrentMillis();
    79    cout << "Got current time" << endl;
    8077
    8178   Player targetP = mapPlayers[target];
    82    cout << "Got target" << endl;
    8379
    8480   if (timeLastUpdated == 0) {
     
    9288   float dist = sqrt(pow(targetP.pos.x-pos.x, 2) + pow(targetP.pos.y-pos.y, 2));
    9389
    94    cout << "About to finish projectile move" << endl;
    95 
    9690   if (dist <= pixels) {
    9791      pos.x = targetP.pos.x;
Note: See TracChangeset for help on using the changeset viewer.