Пример #1
0
void PhysicsObject::MoveUpdate(void)
{
	if (m_airborne)
	{
		// Apply gravity to vertical spatial velocity
		m_spatialKin.ApplyGravity(m_gravityForce);
	
		// Keep track of the height, to know when the object has landed
		m_spatialKin.UpdateHeight();

		// Update velocity and position values
		m_screenKin.velocity.y = m_additiveScreenVelocity.y - m_spatialKin.velocity.y;
		m_pos.x += m_screenKin.velocity.x;
		m_pos.y += m_screenKin.velocity.y;
	
		if (m_spatialKin.height < 0) //Has hit the ground
		{
			// Call any overridden OnLanding code
			OnLanding();

			// This is no longer airborne
			m_airborne = false;

			// Snap the PhysicsObject to its target position (just to make sure, completely and surely)
			m_pos.x = m_endPos.x;
			m_pos.y = m_endPos.y;

			//Stop all movement
			m_spatialKin.Clear();
			m_screenKin.Clear();
		}
	}
}
Пример #2
0
inline void
GlideComputer::TakeoffLanding(bool last_flying)
{
  if (Calculated().flight.flying && !last_flying)
    OnTakeoff();
  else if (!Calculated().flight.flying && last_flying)
    OnLanding();
}
Пример #3
0
void
GlideComputer::TakeoffLanding()
{
  if (Calculated().flight.flying && !LastCalculated().flight.flying)
    OnTakeoff();
  else if (!Calculated().flight.flying && LastCalculated().flight.flying)
    OnLanding();
}