コード例 #1
0
ファイル: Game.cpp プロジェクト: AlexKordic/libRocket
void Game::RemoveLife()
{	
	if (defender_lives > 0)
	{
		SetLives(defender_lives - 1);

		if (defender_lives == 0)
		{
			OnGameOver();
		}
	}
}
コード例 #2
0
ファイル: Game.cpp プロジェクト: AlexKordic/libRocket
void Game::Initialise()
{
	// Initialise the scores and wave information
	SetScore(0);
	SetWave(1);
	SetHighScore(HighScores::GetHighScore());
	SetLives(NUM_LIVES);

	// Initialise the shields.
	InitialiseShields();

	// Create a new wave
	InitialiseWave();
}
コード例 #3
0
ファイル: player.cpp プロジェクト: lukezimmerer/Arkanoid
void Player::Reset()
{
	m_paddle.Reset();
	SetPoints(0);
	SetLives(DEFAULT_LIVES);
}
コード例 #4
0
ファイル: Player.cpp プロジェクト: dtbinh/FinalProject2
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
Summary: Updates the player!
Parameters:
[in] _elapsedTime - the time passed since the last frame.
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
bool CPlayer::Update( float _elapsedTime )
{
	static bool once = false;
	// Timer for death animation.
	if( m_DeathTimer > 0.0f )
	{
		m_DeathTimer -= _elapsedTime;
		
		m_StopAnimSwitching = true;
		if( GetLives() <= 1 )
		{
				
			if( !once )
			{
				GetAnimationManager()->SwitchAnimation(CAssetManager::GetInstance()->GetAnimation(ET_PLAYER, PL_LOSE), 0.5f);
				AudioSystemWwise::GetInstance()->PostEvent(AK::EVENTS::STOP_MX_TRACK_04);
				AudioSystemWwise::GetInstance()->PostEvent(AK::EVENTS::STOP_MX_TRACK_03);
				AudioSystemWwise::GetInstance()->PostEvent(AK::EVENTS::STOP_MX_TRACK_02);
				AudioSystemWwise::GetInstance()->PostEvent(AK::EVENTS::STOP_MX_TRACK_01);
				AudioSystemWwise::GetInstance()->PostEvent(AK::EVENTS::PLAY_MX_TRACK_02);
				SetLives(0);
				once = true;
			}
		}
		else
		{
			GetAnimationManager()->SwitchAnimation(CAssetManager::GetInstance()->GetAnimation(ET_PLAYER, PL_DEATH), 0.3f);
		}
			
		if(m_DeathTimer <= 0.0f)
		{
			SetIsDying(true);
			SetKillScreen(true);
			once = false;

			if( GetLives() == 0 )
			{
				m_DeathTimer = 0.0f;
				return true;
			}

			m_ResetWave = true;
			m_DeathTimer = 0.0f;
		}
		GetAnimationManager()->Update(_elapsedTime, &GetRenderNode());
		return true;
	}

	if(this->GetHealth() <= 25)
	{
		m_LowHPTimer += _elapsedTime;
		if(m_LowHPTimer > 1.5f)
		{
			m_LowHPTimer = 0.0f;
//			AudioSystemWwise::GetInstance()->PostEvent(AK::EVENTS::PLAY_FX_2D_BEEP);
		}
	}

	if(this->m_HealthPickup >= 0.0f)
	{
		static bool healthpickupcolor = false;
		if(healthpickupcolor)
		{
			//GetRenderNode().hTextureDiffuse = CAssetManager::GetInstance()->GetObjData(ET_PLAYER).m_DiffuseHandle;
			GetRenderNode().SetDiffuseTextureHandle( CAssetManager::GetInstance()->GetObjData(ET_SMALLENEMY).m_DiffuseHandle );
		}
		else
		{
			GetRenderNode().SetDiffuseTextureHandle( CAssetManager::GetInstance()->GetObjData(ET_PLAYER).m_DiffuseHandle );
		}
		m_HealthPickup -= HEALTH_PICKUP_BLINKING_TIME;
		healthpickupcolor = !healthpickupcolor;
	}
	else
	{
		GetRenderNode().SetDiffuseTextureHandle( CAssetManager::GetInstance()->GetObjData(ET_PLAYER).m_DiffuseHandle );
	}

	if( GetIsDying() )
	{
		SetIsDying(false);
		SetKillScreen(false);
		//m_StopAnimSwitching = false;

		Vec3f direction;
		glsLoadVector3(direction, 0.0f, 0.0f, 0.0f);
		glsCopyVector3(*GetPosition(), direction);
		GetRenderNode().SetPosition( direction );

		ResetMatrix();
	}

	//	Vec3f direction;
	//	glsLoadVector3(direction, 0.0f, 0.0f, 0.0f);

	//	// Gets the two distances between the north and south pole (possibly in need of optimizations later).
	//	float SDist = glsGetDistance3(direction, GetRenderNode().m_vPosition);
	//	glsLoadVector3(direction, 0.0f, 150.0f, 0.0f);
	//	float NDist = glsGetDistance3(direction, GetRenderNode().m_vPosition);
	//	// finds the shortest one so it can travel to that one
	//	bool HeadinNorth = NDist < SDist ;

	//	// resets the vector if heading to the south
	//	if(!HeadinNorth)
	//		glsLoadVector3(direction, 0.0f, 0.0f, 0.0f);

	//	// gets the directional vector
	//	glsSubtractVectors3(direction, direction, GetRenderNode().m_vPosition);
	//	glsNormalizeVector3(direction);
	//	glsScaleVector3(direction, 30.0f * _elapsedTime);
	//	
	//	// moves the player by that direction by elapsedTime
	//	glsAddVectors3(GetRenderNode().m_vPosition, GetRenderNode().m_vPosition, direction);

	//	// if the distance is small enough the player stops moving
	//	//glsLoadVector3(direction, 0.0f, 0.0f, 0.0f);
	//	if( (HeadinNorth ? NDist : SDist) <= 0.5f )
	//	{
	//		SetIsDying(false);
	//		m_StopAnimSwitching = false;
	//		ResetMatrix();
	//		GetAnimationManager()->SwitchAnimation(CAssetManager::GetInstance()->GetAnimation(ET_PLAYER, PL_IDLE), 0.01f);
	//	}

	//	// copying the player's new position%
	//	glsCopyVector3(*this->GetPosition(), GetRenderNode().m_vPosition);
	//	
	//	// remaking the player's up vector
	//	Vec3f world = { 0.0f, 75.0f, 0.0f };
	//	glsSubtractVectors3(direction, world, GetRenderNode().m_vPosition);

	//	glsNormalizeVector3(direction);
	//	glsCopyVector3(GetRenderNode().m_vUp, direction);

	//	glsCrossProduct3( this->GetRenderNode().m_vForward, this->GetRenderNode().m_vRight, this->GetRenderNode().m_vUp );
	//	glsNormalizeVector3( this->GetRenderNode().m_vForward );

	//	glsCrossProduct3( this->GetRenderNode().m_vRight, this->GetRenderNode().m_vUp, this->GetRenderNode().m_vForward );
	//	glsNormalizeVector3( this->GetRenderNode().m_vRight );

	//	// returing out so no other calcualtions are done.
	//	GetAnimationManager()->Update(_elapsedTime, &GetRenderNode());
	//	return true;
	//}

	if( m_PullTimer > 0.0f )
		m_PullTimer -= _elapsedTime;
	else if( m_PullTimer < 0.0f )
		m_PullTimer = 0.0f;

	if( m_PushTimer > 0.0f )
		m_PushTimer -= _elapsedTime;
	else if( m_PushTimer < 0.0f )
		m_PushTimer = 0.0f;

	m_Gun.AddTime(_elapsedTime);

	// Orient the movement
	glsCopyVector3(m_MoveUp, this->GetRenderNode().GetUpVector());
	glsCrossProduct3( m_MoveForward, m_MoveRight, m_MoveUp );
	glsNormalizeVector3( m_MoveForward );

	glsCrossProduct3( m_MoveRight, m_MoveUp, m_MoveForward );
	glsNormalizeVector3( m_MoveRight );

	// Update the velocities.
	UpdateVelocity();

	m_PosXOffset += (*this->GetVelocity())[0] * _elapsedTime;
	m_PosYOffset += (*this->GetVelocity())[1] * _elapsedTime;

	// Call parents update
	CLivingEntity::Update(_elapsedTime);

	// Update player specific data.
	// Player position	
	GetRenderNode().SetPosition( ((const float *)(*GetPosition())) );

	if( m_JumpTimer > 0.0f )
	{
		m_JumpTimer -= _elapsedTime;
	}
	else if( m_JumpTimer < 0.0f )
		m_JumpTimer = 0.0f;



	//////////////////////////////////////////////
	// Debug Code
	//////////////////////////////////////////////
	//if( GetAsyncKeyState('P') & 0x01 )
	//{
	//	std::cout << "HUD INFO:\n";
	//	std::cout << "HP : " << this->GetHealth() << '/' << MAX_HP_PLAYER << std::endl;
	//	std::cout << "Lives : " << this->GetLives() << std::endl;
	//	std::cout << "Ammo : " << this->GetGun().GetShotTotal() << std::endl;
	//	std::cout << "Curr Gun : " << this->GetGun().GetConsumed() << std::endl;
	//}

	//HAX
	//AUTH: Ryan
	//Desc: feedback for player hurt, replace with animation / effect later
	//Date: ????
	static float hurtTimer = 0.0f;
	if(m_Hurt)
	{
		GetRenderNode().SetColor(1.0f, 0.2f, 0.2f, 1.0f);
		hurtTimer += _elapsedTime;
		if(hurtTimer >= 0.5f)
		{
			//this->GetRenderNode().hTextureDiffuse = CAssetManager::GetInstance()->GetObjData(ET_PLAYER).m_DiffuseHandle;
			GetRenderNode().SetColor(1.0f, 1.0f, 1.0f, 1.0f);
			hurtTimer = 0.0f;
			m_Hurt = false;
		}
	}

	glsCopyVector3(((Sphere*)this->GetCollisionEntity())->m_Center, this->GetRenderNode().GetPosition());
	return true;
}