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


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

本文整理汇总了C++中Projectile::GetRadius方法的典型用法代码示例。如果您正苦于以下问题:C++ Projectile::GetRadius方法的具体用法?C++ Projectile::GetRadius怎么用?C++ Projectile::GetRadius使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Projectile的用法示例。


在下文中一共展示了Projectile::GetRadius方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: CheckCollisionWith

void Player::CheckCollisionWith(Player* iSecond)
{
	Projectile* first = NULL; 
	Projectile* second = NULL;

	for(int i=0; i<mProjectiles.size(); ++i)
	{
		first = mProjectiles[i];
		bool collision = false;
		for(int j=0; j<iSecond->GetProjectilesSize() && !collision; ++j)
		{
			second = iSecond->GetProjectileAt(j);
			if(Distance(first->GetPos(), second->GetPos()) < first->GetRadius() + second->GetRadius())
			{
				//Collision: for the moment remove
				if((mID != iSecond->GetID()))
				{
					collision = true;
					RemoveProjectileAt(i);
					iSecond->RemoveProjectileAt(j);
					--i;
					--j;
				}
				else if(mID == iSecond->GetID() && i != j)
				{
					collision = true;
					RemoveProjectileAt(i);
					//////////////// NB: in this case first and second ARE the same player.
					// Then we are removing TWO bullets of his.
					// If we remove first bullet at index i, with i>j:
					//
					// Before erase
					// [][][][][j][][][i] 
					// 
					// After erase
					// [][][][][j][][]   -----------> projectile after erase has still got index "j"
					//
					//
					// If index  i<j:
					// 
					// Before erase
					// [][i][][j]
					//
					// After erase
					// [][][j]         -----------> projectile after erase has got index "j - 1"


					if(i>j)
						iSecond->RemoveProjectileAt(j);
					else
						iSecond->RemoveProjectileAt(j-1);
				}
			}

		}

	}

}
开发者ID:JacopoV,项目名称:MoonCraft,代码行数:59,代码来源:Player.cpp

示例2: Add

void Projectile::Add(Body *parent, Equip::Type type, const vector3d &pos, const vector3d &baseVel, const vector3d &dirVel)
{
	Projectile *p = new Projectile();
	p->m_parent = parent;
	p->m_type = Equip::types[type].tableIndex;
	p->SetFrame(parent->GetFrame());
	
	parent->GetRotMatrix(p->m_orient);
	p->SetPosition(pos);
	p->m_baseVel = baseVel;
	p->m_dirVel = dirVel;
	p->m_radius = p->GetRadius();
	Pi::game->GetSpace()->AddBody(p);
}
开发者ID:Thargoid,项目名称:pioneer,代码行数:14,代码来源:Projectile.cpp


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