Beispiel #1
0
//-----------------------------------------------------------------------------
// Rotates the player's view.
//-----------------------------------------------------------------------------
void PlayerObject::MouseLook( float x, float y, bool reset )
{
	static float lastX = 0.0f;
	static float lastY = 0.0f;

	// Check if the player's view needs to be reset.
	if( reset == true )
	{
		lastX = lastY = 0.0f;
		SetRotation( 0.0f, 0.0f, 0.0f );
		m_viewTilt = 0.0f;
		return;
	}

	// Calculate the real x and y values by accounting for smoothing.
	lastX = lastX * m_viewSmoothing + x * ( 1.0f - m_viewSmoothing );
	lastY = lastY * m_viewSmoothing + y * ( 1.0f - m_viewSmoothing );

	// Adjust the values for sensitivity.
	lastX *= m_viewSensitivity;
	lastY *= m_viewSensitivity;

	// Rotate the scene object around the y axis only. This will prevent the
	// player's mesh from rotating when the player looks up and down.
	AddRotation( 0.0f, lastY, 0.0f );

	// Ensure the view will not rotate to far up or down.
	if( ( m_viewTilt > 0.8f && lastX > 0.0f ) || ( m_viewTilt < -0.8f && lastX < 0.0f ) )
		lastX = 0.0f;

	// Maintain a seperate view rotation around the x axis to allow the player
	// to look up and down.
	m_viewTilt += lastX;
}
Beispiel #2
0
void Canister::Update(float DeltaTime, Terrain* terrain)
{
	XMFLOAT3	newPos	=	GetFloat3Value( Position );

	if ( !gPointLight )
	{
		gPointLight	=	new PointLight();
		gPointLight->GetGPULight()->Color		=	XMFLOAT4( 0.0f, 0.0f, 1.0f, 0.0f );
		gPointLight->GetGPULight()->Position	=	newPos;
		gPointLight->GetGPULight()->Range		=	33.333f * 0.40f;
		gPointLight->GetGPULight()->HasShadow	=	false;

		AddLight( gPointLight );
	}

	gTimeSpan	+=	DeltaTime;

	XMVECTOR QuatV = XMQuaternionRotationRollPitchYaw(0, DeltaTime, 0);
	XMFLOAT4 Quat;

	XMStoreFloat4(&Quat, QuatV);
	AddRotation( Quat );
	newPos.y	=	gOffset.y + ( gOffset.y - 2 ) * sin( 8 * gTimeSpan );
	MoveTo( newPos );
	newPos.y	-=	1.0f;
	if ( gPointLight )
		gPointLight->GetGPULight()->Position	=	newPos;

	Item::Update( DeltaTime, terrain );
}
list <shared_ptr<SFProjectile>> SFBoss::Phase3(){
  list<shared_ptr<SFProjectile>> bullets;
  //every second
  if(phase_timer%(60*1) == 0){
    bullets.splice(bullets.end(),pattern->CreateExplosion(GetPosition(),p_dir));
    AddRotation(30);
  }
  //
  if(phase_timer%(45*2) == 0){
    bullets.splice(bullets.end(),pattern->CreateExplosion(GetPosition(),0));
  }
  //
  if(phase_timer%(45*2) == 0){
    bullets.splice(bullets.end(),pattern->SprayAt(GetPosition(),player->GetPosition()));
  }

  return bullets;
}
Beispiel #4
0
// Updates the object.
void SceneObject::Update( float elapsed, bool addVelocity )
{
	// Calculate the friction for this update.
	float friction = 1.0f - m_friction * elapsed;

	// Move the object.
	m_velocity *= friction;

	// Check if there is velecity to to be added into the translation
	if( addVelocity == true )
	{
		D3DXVECTOR3 velocity = m_velocity * elapsed;
		AddTranslation( velocity.x, velocity.y, velocity.z );
	}

	// Spin the object.
	m_spin *= friction;
	D3DXVECTOR3 spin = m_spin * elapsed;
	AddRotation( spin.x, spin.y, spin.z );

	// Update the object's world matrix.
	D3DXMatrixMultiply( &m_worldMatrix, &m_rotationMatrix, &m_translationMatrix );

	// Create a view matrix for the object.
	D3DXMatrixInverse( &m_viewMatrix, NULL, &m_worldMatrix );

	// Update the object's forward vector.
	m_forward.x = (float)sin( m_rotation.y );
	m_forward.y = (float)-tan( m_rotation.x );
	m_forward.z = (float)cos( m_rotation.y );
	D3DXVec3Normalize( &m_forward, &m_forward );

	// Update the object's right vector.
	m_right.x = (float)cos( m_rotation.y );
	m_right.y = (float)tan( m_rotation.z );
	m_right.z = (float)-sin( m_rotation.y );
	D3DXVec3Normalize( &m_right, &m_right );

	// Update the object's bounding volume using the translation matrix only.
	// This will maintain an axis aligned bounding box around the object in
	// world space rather than the object's local space.
	RepositionBoundVolume( &m_translationMatrix );

}
list <shared_ptr<SFProjectile>> SFBoss::Phase2(){
  list<shared_ptr<SFProjectile>> bullets;
  //every 2 seconds
  if(phase_timer%(60*2) == 0){
    bullets.splice(bullets.end(),pattern->SprayAt(GetPosition(),player->GetPosition()));
  }
  //every half second
  if(phase_timer%(30*1) == 0){
    bullets.splice(bullets.end(),pattern->FireAngle(GetPosition(),p_dir));
    bullets.splice(bullets.end(),pattern->FireAngle(GetPosition(),p_dir+180));
    bullets.splice(bullets.end(),pattern->FireAngle(GetPosition(),p_dir+90));
    bullets.splice(bullets.end(),pattern->FireAngle(GetPosition(),p_dir+270));
    AddRotation(20);
  }
  //every 4 seconds starting at 2s
  if(phase_timer%(60*8) == 4*60){
    bullets.splice(bullets.end(),pattern->CreateExplosion(GetPosition(),0));
  }
  return bullets;
}