本文整理汇总了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);
}
}
}
}
}
示例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);
}