Changeset e6c26b8 in network-game for common/Projectile.cpp
- Timestamp:
- Oct 1, 2013, 8:08:24 PM (11 years ago)
- Branches:
- master
- Children:
- 95ffe57
- Parents:
- 373089e
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
common/Projectile.cpp
r373089e re6c26b8 71 71 } 72 72 73 bool Projectile::move(map<unsigned int, Player >& mapPlayers) {73 bool Projectile::move(map<unsigned int, Player*>& mapPlayers) { 74 74 // if the current target logs off, this method will run into problems 75 75 76 76 unsigned long long curTime = getCurrentMillis(); 77 77 78 Player targetP = mapPlayers[target];78 Player* targetP = mapPlayers[target]; 79 79 80 80 if (timeLastUpdated == 0) { … … 85 85 86 86 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)); 89 89 90 90 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; 93 93 return true; 94 94 }else {
Note:
See TracChangeset
for help on using the changeset viewer.