Changeset e6c26b8 in network-game for common/Projectile.cpp


Ignore:
Timestamp:
Oct 1, 2013, 8:08:24 PM (11 years ago)
Author:
Dmitry Portnoy <dportnoy@…>
Branches:
master
Children:
95ffe57
Parents:
373089e
Message:

The client dynamically allocates memory for players and passes around a map with player pointers and some includes are now in individual files instead of in Common.h

File:
1 edited

Legend:

Unmodified
Added
Removed
  • common/Projectile.cpp

    r373089e re6c26b8  
    7171}
    7272
    73 bool Projectile::move(map<unsigned int, Player>& mapPlayers) {
     73bool Projectile::move(map<unsigned int, Player*>& mapPlayers) {
    7474   // if the current target logs off, this method will run into problems
    7575
    7676   unsigned long long curTime = getCurrentMillis();
    7777
    78    Player targetP = mapPlayers[target];
     78   Player* targetP = mapPlayers[target];
    7979
    8080   if (timeLastUpdated == 0) {
     
    8585
    8686   float pixels = speed * (curTime-timeLastUpdated) / 1000.0;
    87    double angle = atan2(targetP.pos.y-pos.y, targetP.pos.x-pos.x);
    88    float dist = sqrt(pow(targetP.pos.x-pos.x, 2) + pow(targetP.pos.y-pos.y, 2));
     87   double angle = atan2(targetP->pos.y-pos.y, targetP->pos.x-pos.x);
     88   float dist = sqrt(pow(targetP->pos.x-pos.x, 2) + pow(targetP->pos.y-pos.y, 2));
    8989
    9090   if (dist <= pixels) {
    91       pos.x = targetP.pos.x;
    92       pos.y = targetP.pos.y;
     91      pos.x = targetP->pos.x;
     92      pos.y = targetP->pos.y;
    9393      return true;
    9494   }else {
Note: See TracChangeset for help on using the changeset viewer.