当前位置: 首页>>代码示例>>C++>>正文


C++ CBase::SetPosX方法代码示例

本文整理汇总了C++中CBase::SetPosX方法的典型用法代码示例。如果您正苦于以下问题:C++ CBase::SetPosX方法的具体用法?C++ CBase::SetPosX怎么用?C++ CBase::SetPosX使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CBase的用法示例。


在下文中一共展示了CBase::SetPosX方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: HandleEvent

void CGamePlay::HandleEvent(CEvent *pEvent)
{
	CSGD_ObjectFactory<string, CBase> *pOF		= CSGD_ObjectFactory<string, CBase>::GetInstance();
	CSGD_ObjectManager *pOM						= CSGD_ObjectManager::GetInstance();
 	CSGD_TextureManager *pTM = CSGD_TextureManager::GetInstance();

	if (pEvent->GetEventID() == "spawn powerups")
	{
		CBase *tempPowerup;
		int nRandomPowerup = rand() % 100 + 1;

		if (nRandomPowerup <= 30)
			tempPowerup = pOF->CreateObject("CPowerupHealth");
		else if (nRandomPowerup > 30 && nRandomPowerup <= 60)
			tempPowerup = pOF->CreateObject("CPowerupRapidFire");
		else if (nRandomPowerup > 60 && nRandomPowerup <= 90)
			tempPowerup = pOF->CreateObject("CPowerupThreeWay");
		else if (nRandomPowerup > 90)
			tempPowerup = pOF->CreateObject("CPowerup1up");

		tempPowerup ->SetImageID(m_nImageID[3]);
		tempPowerup->SetPosX(CPlayerCharacter::GetInstance()->GetPosX() + 128);
		if (tempPowerup->GetPosX() > 640)
			tempPowerup->SetPosX(640);
		tempPowerup->SetPosY(CPlayerCharacter::GetInstance()->GetPosY() + 32);
		pOM->AddObject(tempPowerup );
		tempPowerup ->Release();
	}

	else if (pEvent->GetEventID() == "scroll right")
	{
		if (GetBridgeOffset() > -100)
		{
			SetBridgeOffset(GetBridgeOffset() - (5 * CGame::GetInstance()->GetSpeed()));
			SetSpaceOffset(GetSpaceOffset() - (15 * CGame::GetInstance()->GetSpeed()));
			for (int i = 0; i < enemies.size(); ++i)
			{
				enemies[i]->SetPosX(enemies[i]->GetPosX() - (5 * CGame::GetInstance()->GetSpeed()));
			}
		}
	}

	else if (pEvent->GetEventID() == "scroll left")
	{
		if (GetBridgeOffset() < 0)
		{
			SetBridgeOffset(GetBridgeOffset() + (5 * CGame::GetInstance()->GetSpeed()));
			SetSpaceOffset(GetSpaceOffset() + (15 * CGame::GetInstance()->GetSpeed()));
			for (int i = 0; i < enemies.size(); ++i)
			{
				enemies[i]->SetPosX(enemies[i]->GetPosX() + (5 * CGame::GetInstance()->GetSpeed()));
			}
		}
	}

	else if (pEvent->GetEventID() == "spawn enemies")
	{
		CBase *tempEnemy;
		if (GetLevel() == 1 && m_nRemainingEnemies > 0 && m_nTotalSpawns < 10)
		{
			m_nEnemyCounter += 1;
			m_nTotalSpawns += 1;

			if (m_nTotalSpawns % 2 == 1)
			{
				tempEnemy = pOF->CreateObject("CEnemyDemon");
				tempEnemy ->SetImageID(m_nImageID[1]);
				pOM->AddObject(tempEnemy );
				tempEnemy ->Release();
				enemies.push_back(tempEnemy);
			}
			else
			{
				tempEnemy = pOF->CreateObject("CEnemyBusiness");
				tempEnemy ->SetImageID(m_nImageID[1]);
				pOM->AddObject(tempEnemy );
				tempEnemy ->Release();
				enemies.push_back(tempEnemy);
			}
	   }
	if (GetLevel() == 2 && m_nRemainingEnemies > 0 && m_nTotalSpawns < 10)
	{
		m_nEnemyCounter += 1;
		m_nTotalSpawns += 1;

		if (m_nTotalSpawns % 2 == 1)
		{
			tempEnemy = pOF->CreateObject("CEnemyMeat");
			tempEnemy ->SetImageID(m_nImageID[2]);
			pOM->AddObject(tempEnemy );
			tempEnemy ->Release();
			enemies.push_back(tempEnemy);
		}
		else
		{
			tempEnemy = pOF->CreateObject("CEnemyBooger");
			tempEnemy ->SetImageID(m_nImageID[2]);
			pOM->AddObject(tempEnemy );
			tempEnemy ->Release();
			enemies.push_back(tempEnemy);
//.........这里部分代码省略.........
开发者ID:jakneute,项目名称:Earthworm-Jim-Full-Sail-Game-Project,代码行数:101,代码来源:GamePlay.cpp


注:本文中的CBase::SetPosX方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。