Changeset ff2133a in network-game for common/Player.cpp


Ignore:
Timestamp:
Jun 11, 2013, 1:24:09 AM (11 years ago)
Author:
dportnoy <dmp1488@…>
Branches:
master
Children:
5b1e31e
Parents:
11d21ee
Message:

Move player chasing behavior to the Player class so the same behavior can be run client-side

File:
1 edited

Legend:

Unmodified
Added
Removed
  • common/Player.cpp

    r11d21ee rff2133a  
    191191   return moving;
    192192}
     193
     194void Player::updateTarget(map<unsigned int, Player>& mapPlayers) {
     195   if (this->isChasing) {
     196      this->target.x = mapPlayers[this->targetPlayer].pos.x;
     197      this->target.y = mapPlayers[this->targetPlayer].pos.y;
     198
     199      if (posDistance(this->pos, this->target.toFloat()) <= this->range) {
     200         this->target.x = this->pos.x;
     201         this->target.y = this->pos.y;
     202
     203         this->isChasing = false;
     204         this->isAttacking = true;
     205         this->timeAttackStarted = getCurrentMillis();
     206      }
     207   }
     208}
Note: See TracChangeset for help on using the changeset viewer.