本文整理汇总了C++中CCircle::OverlapsLineSegment方法的典型用法代码示例。如果您正苦于以下问题:C++ CCircle::OverlapsLineSegment方法的具体用法?C++ CCircle::OverlapsLineSegment怎么用?C++ CCircle::OverlapsLineSegment使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CCircle
的用法示例。
在下文中一共展示了CCircle::OverlapsLineSegment方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: vHeading
void
CMole::UpdatePosition(float _fTimeDelta)
{
CCircle SelfCircle;
CWall* pWalls = 0;
CAcorn* pAcorns = 0;
CMole* pMoles = 0;
int iNumWalls = 0;
int iNumAcorns = 0;
int iNumMoles = 0;
bool bCollision = false;
// Create heading vector
CFVec2 vHeading(0.0f, -1.0f);
vHeading.RotateZ(m_fHeading);
float fMovementVelocity = m_fMovementVelocity + (DIFFICULTY_MOVEMENT_VELOCITY_INCR * m_iDifficultyLevel);
CFVec2 vNextPosition = m_vPosition;
vNextPosition += vHeading * (fMovementVelocity * _fTimeDelta);
SelfCircle.Initialise(vNextPosition, m_fRadius);
CMMMContext& rMMMContext = CMMMContext::GetInstance();
rMMMContext.GetWalls(pWalls, iNumWalls);
rMMMContext.GetAcorns(pAcorns, iNumAcorns);
rMMMContext.GetMoles(pMoles, iNumMoles);
CCircle EntityCircle;
SelfCircle.Initialise(vNextPosition, m_fRadius);
// Check collision against other moles
for (int i = 0; i < iNumMoles; ++ i)
{
if (&pMoles[i] != this)
{
EntityCircle.Initialise(pMoles[i].GetPosition(), pMoles[i].GetRadius());
if (SelfCircle.Overlaps(EntityCircle))
{
bCollision = true;
break;
}
else
{
// Do nothing
}
}
}
if (!bCollision)
{
// Check collision against walls
for (int i = 0; i < iNumWalls; ++ i)
{
if (SelfCircle.OverlapsLineSegment(pWalls[i].GetEnd0(), pWalls[i].GetEnd1()))
{
bCollision = true;
break;
}
}
}
if (!bCollision)
{
m_vPosition = vNextPosition;
}
}
示例2: Intersects
/**
* @param Circle A circle to evaluate to see if it intersects the wall.
* @return true if the circle intersects the wall.
*/
bool CWall::Intersects( const CCircle& Circle ) const
{
return Circle.OverlapsLineSegment( m_vEnd[0], m_vEnd[1] );
}