本文整理汇总了C++中Projectile::Velocity方法的典型用法代码示例。如果您正苦于以下问题:C++ Projectile::Velocity方法的具体用法?C++ Projectile::Velocity怎么用?C++ Projectile::Velocity使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Projectile
的用法示例。
在下文中一共展示了Projectile::Velocity方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Point
double AsteroidField::Asteroid::Collide(const Projectile &projectile, int step) const
{
Point pos = location - projectile.Position();
pos = Point(-remainder(pos.X(), WRAP), -remainder(pos.Y(), WRAP));
return animation.GetMask(step).Collide(pos, projectile.Velocity(), angle);
}
示例2:
// Fire an anti-missile. Returns true if the missile should be killed.
bool Armament::Weapon::FireAntiMissile(Ship &ship, const Projectile &projectile, list<Effect> &effects)
{
int strength = outfit->AntiMissile();
if(!strength)
return false;
double range = outfit->Velocity();
// Check if the missile is in range.
Point start = ship.Position() + ship.Facing().Rotate(point);
Point offset = projectile.Position() - start;
if(offset.Length() > range)
return false;
// Firing effects are displayed at the anti-missile that just fired.
Angle aim = TO_DEG * atan2(offset.X(), -offset.Y());
for(const auto &eit : outfit->FireEffects())
for(int i = 0; i < eit.second; ++i)
{
effects.push_back(*eit.first);
effects.back().Place(start, ship.Velocity(), aim);
}
// Figure out where the effect should be placed. Anti-missiles do not create
// projectiles; they just create a blast animation.
start += (.5 * range) * offset.Unit();
for(const auto &eit : outfit->HitEffects())
for(int i = 0; i < eit.second; ++i)
{
effects.push_back(*eit.first);
effects.back().Place(start, ship.Velocity(), aim);
}
// Die effects are displayed at the projectile, whether or not it actually "dies."
for(const auto &eit : outfit->DieEffects())
for(int i = 0; i < eit.second; ++i)
{
effects.push_back(*eit.first);
effects.back().Place(projectile.Position(), projectile.Velocity(), aim);
}
Fire(ship);
return (Random::Int(strength) > Random::Int(projectile.MissileStrength()));
}