Пример #1
0
void CMole::Update(FLOAT32 _fTimeDelta)
{
	m_pMoleAgent->Update(_fTimeDelta);

	// Turn.
	m_fHeading += m_pMoleAgent->GetRotationalSpeed() * _fTimeDelta;

	// Update position.
	CFVec2 vHeading;
	vHeading.SetToRotationZ(m_fHeading);
	CFVec2 vVelocity = vHeading * m_pMoleAgent->GetSpeed() * _fTimeDelta;
	m_vPosition += vVelocity;

	if ((m_vDestination - m_vPosition).Magnitude() < fMOLE_RADIUS)
	{
		Messages::send(DESTINATION_REACHED_EVENT, this);
	}

	// finally check if that pesky rodent got caught:
	CCircle Bounds;
	Bounds.Initialise( m_vPosition, fMOLE_RADIUS );
	if ( CMMMContext::GetInstance().GetSquirrel()->Intersects( Bounds ) )
	{
		CMMMContext::GetInstance().GetSquirrel()->LoseLife();
		Messages::send(DESTINATION_REACHED_EVENT, this);
	}
}