Exemple #1
0
bool
CMole::Intersects(const CCircle& _krCircle) const
{
	CCircle Bounds;
	Bounds.Initialise(m_vPosition, m_fRadius);


	return (_krCircle.Overlaps(Bounds));
}
bool CSquirrel::Intersects( const CCircle& Circle ) const
{
	CCircle Bounds;
	Bounds.Initialise( m_vPosition, m_fRadius );
	return Circle.Overlaps( Bounds );
}
Exemple #3
0
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;
	}
}
Exemple #4
0
bool CMole::Intersects( const CCircle& Circle ) const
{
	CCircle Bounds;
	Bounds.Initialise( m_vPosition, fMOLE_RADIUS );
	return Circle.Overlaps( Bounds );
}