本文整理汇总了C++中Tank::GetDistanceTo方法的典型用法代码示例。如果您正苦于以下问题:C++ Tank::GetDistanceTo方法的具体用法?C++ Tank::GetDistanceTo怎么用?C++ Tank::GetDistanceTo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Tank
的用法示例。
在下文中一共展示了Tank::GetDistanceTo方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: EnemyBlocked
bool EnemyBlocked( Tank * pEnemy, Tank & self, vector<Tank> & t )
{
double my_angle = self.GetAngleTo( *pEnemy );
double my_dist = self.GetDistanceTo( *pEnemy );
for (int i = 0; i < t.size(); ++i)
{
if (t[i].id() == pEnemy->id() || t[i].id() == self.id())
{
continue;
}
double max_wh = std::max( t[i].width(), t[i].height() );
double alpha = fabs( self.GetAngleTo(t[i]) - my_angle );
double his_dist = self.GetDistanceTo( t[i] );
if (alpha > M_PI / 4)
{
continue;
}
double d_size = sin(alpha) * my_dist;
if ( d_size <= max_wh/2 && his_dist < my_dist )
{
return true;
}
}
return false;
}
示例2: GoToUnit
void GoToUnit( Unit * pBonus, Tank & self, model::Move & move )
{
double orig_angle = self.GetAngleTo(*pBonus);
double angle = orig_angle;
double fangle = fabs(orig_angle);
double dist = self.GetDistanceTo( *pBonus );
double MIN_ANGLE_B = dist*0.0005;
double direction = 1.0;
if (orig_angle > PI_D_2)
{
angle = M_PI - fangle;
direction = -1.0;
}
if (orig_angle < -PI_D_2)
{
angle = fangle - M_PI;
direction = -1.0;
}
if (fangle > PI_D_2)
{
if ( angle > MIN_ANGLE_B )
{
move.set_left_track_power(-self.engine_power());
move.set_right_track_power( self.engine_power() - self.engine_rear_power_factor() ); //(.75);
}
else if ( angle < -MIN_ANGLE_B )
{
move.set_left_track_power(self.engine_power() - self.engine_rear_power_factor() );//(.75);
move.set_right_track_power(-self.engine_power());
}
else
{
move.set_left_track_power(direction*1);
move.set_right_track_power(direction*1);
}
}
else
{
if ( angle > MIN_ANGLE_B )
{
move.set_left_track_power(self.engine_power() - self.engine_rear_power_factor() );//(.75);
move.set_right_track_power(-self.engine_power());
}
else if ( angle < -MIN_ANGLE_B )
{
move.set_left_track_power(-self.engine_power());
move.set_right_track_power( self.engine_power() - self.engine_rear_power_factor() ); //(.75);
}
else
{
move.set_left_track_power(direction*1);
move.set_right_track_power(direction*1);
}
}
}
示例3: ForceModify
void ForceModify(Tank & self, Unit & u, double & xForce, double & yForce, double neg_c)
{
//double absBearing = fabs( u.angle() );
double absBearing = self.GetAngleTo( u );
/* from 0 to 2*PI */
double distance = self.GetDistanceTo( u );
xForce += neg_c * ( sin(absBearing) / (distance * distance) );
yForce += neg_c * ( cos(absBearing) / (distance * distance) );
}
示例4: Unit
Corner(Tank & self, double cx, double cy, CornerType cid)
: Unit( 0.0, 0.0, 0.0, cx, cy, 0.0, 0.0, 0.0, 0.0 )
, dist( self.GetDistanceTo(cx, cy) )
, id( cid )
{
}