Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Jul 4, 2006, 6:16:00 PM (18 years ago)
Author:
patrick
Message:

aiming system integration

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/presentation/src/world_entities/weapons/aiming_system.cc

    r9160 r9163  
    7676/**
    7777 * get back the nearest target
     78 * @returns the nerest target
    7879 */
    7980inline WorldEntity* AimingSystem::getNearestTarget()
     
    8485    return this->selectionList.back();
    8586
    86 //   WorldEntity* nearestEntity = this->;
     87  WorldEntity* nearestEntity     = this->selectionList.back();
     88  float        distance          = 0.0f;
     89  float        smalestDistance   = this->range * 5.0f;
     90
    8791
    8892  for( int i = 0; i < this->selectionList.size(); i++)
    8993  {
     94    distance = fabs((this->getAbsCoor() - this->selectionList[i]->getAbsCoor()).len());
     95    if( distance < smalestDistance)
     96    {
     97      nearestEntity = this->selectionList[i];
     98      smalestDistance = distance;
     99    }
     100  }
    90101
    91   }
     102  return nearestEntity;
    92103}
    93104
     
    111122void AimingSystem::tick(float dt)
    112123{
     124
     125  this->selectionList.clear();
    113126}
    114127
Note: See TracChangeset for help on using the changeset viewer.