当前位置: 首页>>代码示例>>C++>>正文


C++ Projectile::Velocity方法代码示例

本文整理汇总了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);
}
开发者ID:AJMansfield,项目名称:endless-sky,代码行数:7,代码来源:AsteroidField.cpp

示例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()));
}
开发者ID:Arnogax,项目名称:endless-sky,代码行数:46,代码来源:Armament.cpp


注:本文中的Projectile::Velocity方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。