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


C++ Enemy::Initialise方法代码示例

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


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

示例1: Enemy

void
Game::SpawnEnemy(float x, float y)
{
	Enemy* e = new Enemy();
	Sprite* rabbitLeft = m_pBackBuffer->CreateSprite("assets\\rabbit.png");
	e->Initialise(rabbitLeft);
	e->SetPositionX(x);
	e->SetPositionY(y);
	e->SetHorizontalVelocity(-0.5f);
	m_EnemyVector.push_back(e);
}
开发者ID:Sisky,项目名称:Game-Programming,代码行数:11,代码来源:game.cpp

示例2: Enemy

// Ex006.3: Spawn a Enemy in game.
void 
Game::SpawnEnemy(int x, int y)
{
	// Ex006.3: Load the alien enemy sprite file.
	Sprite* pEnemySprite = m_pBackBuffer->CreateSprite("assets\\alienenemy.png");
	// Ex006.3: Create a new Enemy object. 
	Enemy* enemy = new Enemy();
	// set center handles
	pEnemySprite->SetHandleCenter();
	// Initialize the enemy object
	enemy->Initialise(pEnemySprite);
	// set the position of the Enemy object 
	enemy->SetPositionX(x);
	enemy->SetPositionY(y);


	// Ex006.3: Add the new Enemy to the enemy container.
	m_enemyShip.push_back(enemy);
}
开发者ID:D4vx,项目名称:SDL-Framework,代码行数:20,代码来源:game.cpp

示例3: frameRenderingQueued

//-------------------------------------------------------------------------------------
bool BaseApplication::frameRenderingQueued(const Ogre::FrameEvent& evt)
{
    if(mWindow->isClosed())
        return false;

    if(mShutDown)
        return false;

    //Need to capture/update each device
    mKeyboard->capture();
    mMouse->capture();

    mTrayMgr->frameRenderingQueued(evt);
	FModManager::System()->update();

    if (!mTrayMgr->isDialogVisible())
    {
        //mCameraMan->frameRenderingQueued(evt);   // if dialog isn't up, then update the camera
        if (mDetailsPanel->isVisible())   // if details panel is visible, then update its contents
        {
            mDetailsPanel->setParamValue(0, Ogre::StringConverter::toString((int)charge));
            mDetailsPanel->setParamValue(2, Ogre::StringConverter::toString(mCamera->getDerivedPosition().z));
            mDetailsPanel->setParamValue(4, Ogre::StringConverter::toString(mCamera->getDerivedOrientation().w));
            mDetailsPanel->setParamValue(5, Ogre::StringConverter::toString(mCamera->getDerivedOrientation().x));
            mDetailsPanel->setParamValue(6, Ogre::StringConverter::toString(mCamera->getDerivedOrientation().y));
            mDetailsPanel->setParamValue(7, Ogre::StringConverter::toString(mCamera->getDerivedOrientation().z));
        }
    }

	if(gameStarted == true)
	{
		if(myTimer.getMilliseconds() >= difficulty && mEnemies.size() < numEnemies)
		{
			number = Ogre::StringConverter::toString(numEnemy + 1);
			// Add the current element number to the entity/scene node name to avoid confusion
			Ogre::Entity* myEnt = mSceneMgr->createEntity("enemy " + number, "ninja.mesh");	
			mNodes.push_back(mSceneMgr->getRootSceneNode()->createChildSceneNode("Node " + number));
			////// Distance the nodes from each other, so they aren't at the same place, and then attach them
			mNodes.at(numEnemy)->setPosition((numEnemy) * -50 , 0, 0); 
			mNodes.at(numEnemy)->attachObject(myEnt);
			mNodes.at(numEnemy)->scale(0.2,0.2,0.2);
			Enemy* ninja = new Enemy(mNodes.at(numEnemy), Ogre::Vector3(0, 0, 0), cannons[myTimer.getMilliseconds()%3]->getPosition(), myTimer.getMilliseconds()%3);
			ninja->Initialise();
			mEnemies.push_back(ninja);
			numEnemy++;
			myTimer.reset();
		}
	}

	//if the game is not over
	if(endGame == false)
	{
		//check if cannons health are 0 
		if(cannons[0]->getHealth() <= 0 && cannons[1]->getHealth() <= 0 
			&& cannons[2]->getHealth() <= 0)
		{
			//end the game and call the endgame menu
			endGame = true;
			endGameMenu();
		}

		count = 0;


		for(int i = 0; i < mEnemies.size(); i++)
		{
			//count all of the enemies that are dead
			if(mEnemies[i]->isAlive() == false)
			{
				count++;
			}
		
		}

		if(gameStarted == true)
		{
			//if the number of dead enemies are the same
			//as the amount in the vector call gameOver
			if(count == numEnemy)
			{
				endGame = true;
				endGameMenu();
			}
		}
	}


	double timeChange = evt.timeSinceLastFrame;


	//update Panel
	 mPanel->injectTime(evt.timeSinceLastFrame);

	 if(gameStarted == true)
	 {
		 mPanel->mNode->setPosition(0,-2000,0);
 
        // Quit on ESCAPE Keyboard
        mKeyboard->capture();
//.........这里部分代码省略.........
开发者ID:ChrisSherlock91,项目名称:Project,代码行数:101,代码来源:BaseApplication.cpp


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