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


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

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


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

示例1: Enemy

EnemyManager::EnemyManager(char* filename, Ogre::SceneManager* _inMgr, Blocks* block_ent)
{
	vData.clear();
	vEnemy.clear();
	ReadXmlEnemyData(filename);

	for (int i = 0; i < vData.size(); i++) {
		Ogre::Vector3 startPos = Ogre::Vector3(vData[i].x, vData[i].y, vData[i].z);
		Ogre::Vector3 pos = block_ent->absToRealPos(startPos);
		Enemy* enemy = new Enemy(_inMgr, Ogre::Vector3(pos.x, pos.y-25, pos.z), startPos);
		vEnemy.push_back(enemy);
		enemy->Initialize();
		enemy->InitCmdVector(vData[i].vCmd);
	}
}
开发者ID:sieg-lu,项目名称:dimensional-sinbad,代码行数:15,代码来源:EnemyManager.cpp

示例2: AddEnemy

//=============================================================================================================
void Game::AddEnemy(int type, int height, int width, int track, int speed)
{
	if( height > 3 || height < 1 )
		return;

	DummyFramework::CSprite9*	sprite;

	D3DXVECTOR2		position;
	Enemy*			enemy;
	float			h = (float)height;
	float			d = GameVariables::PlayFieldHeight;
	float			start = (GameVariables::ScreenHeight - d) * 0.5f;
	float			tw;
	int			cnt;

	// elöször meg kell tudni, hogy melyik grafika lesz
	switch( type )
	{
	case 0:
		sprite = &atlas1["regular"];
		break;

	case 1:
		sprite = &atlas1["worm"];
		break;

	case 2:
		sprite = &atlas1["bomb"];
		break;

	case 3:
		sprite = &atlas1["island"];
		break;

		/*
	case 4:
		sprite = &atlas1["elite"];
		break;
		*/

	case 5:
		sprite = &atlas1["razor"];
		break;

	default:
		break;
	}

	// aztán kiszámolni a helyzetét
	float yspacing = (d - 3.0f * sprite->Size.y) / 4.0f;
	float xspacing = 20;

	if( track == 0 )
	{
		position.y = start + yspacing + sprite->Size.y * 0.5f;
		yspacing = (4.0f - h) * yspacing + (3.0f - h) * sprite->Size.y;
	}
	else if( track == 1 )
	{
		float center = start + d * 0.5f;
		position.y = center - (h - 1) * 0.5f * (sprite->Size.y + yspacing);
	}
	else if( track == 2 )
	{
		position.y = GameVariables::ScreenHeight - start - yspacing - sprite->Size.y * 0.5f;
		yspacing = -((5 - h) * sprite->Size.y + (4 - h) * yspacing);
	}

	// és létrehozni a megfelelö származtatott objektumot
	switch( type )
	{
	case 0:
		for( int i = 0; i < height; ++i )
		{
			position.x = GameVariables::ScreenWidth + sprite->Size.x;

			for( int j = 0; j < width; ++j )
			{
				enemy = new Enemy();

				enemy->shoot.connect(this, &Game::enemy_shoot1);
				enemy->explode.connect(this, &Game::enemy_explode);
				enemy->dead.connect(this, &Game::enemy_dead);

				enemy->Initialize(*game);
				enemy->Image = sprite;
				enemy->Hurt = &atlas1["hurt"];
				enemy->Speed = GameVariables::CorrelateW((float)speed);
				enemy->SetPosition(position);

				enemies.insert(enemy);
				position.x += (sprite->Size.x + xspacing);
			}

			position.y += (sprite->Size.y + yspacing);
		}
		break;

	case 1:
//.........这里部分代码省略.........
开发者ID:asylum2010,项目名称:DummyFramework,代码行数:101,代码来源:game.cpp


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