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


C++ StaticObject::moveAwayFromPlayer方法代码示例

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


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

示例1: BasicEnemy

void IceWorld::loadPhase2(irr::IrrlichtDevice * device){
	//Unload the terrains from the scene
	clearTerrains();

	//Make sure the previous phase is no longer considered loaded
	phase1Loaded = false;

	//Get the references
	irr::scene::ISceneManager *smgr = device->getSceneManager();
	irr::video::IVideoDriver *driver = device->getVideoDriver();

	//Set the random seed
	srand(1);

	//Reset the player position
	player->changePosition(irr::core::vector3df(0, 0, 0));

	//Make an array for the spawn order
	int spawnOrder[10] = {1, 1, 2, 1, 2, 3, 1, 1, 3, 2};

	//Set up the enemy positions
	irr::f32 x = 0; irr::f32 y = 0; irr::f32 z = 500;
	for(int i = 0; i < 20; i++){
		//Deside which enemy to place
		if(spawnOrder[i] == 1){
			BasicEnemy *basicEnemy = new BasicEnemy(player, irr::core::vector3df(x, y, z), device->getTimer(), smgr);
		} else if(spawnOrder[i] == 2){
			FastEnemy *fastEnemy = new FastEnemy(player, irr::core::vector3df(x, y, z), device->getTimer(), smgr);
		} else if(spawnOrder[i] == 3){
			StrongEnemy *strongEnemy = new StrongEnemy(player, irr::core::vector3df(x, y, z), device->getTimer(), smgr);
		}
		z += 1500 + (player->getMovementSpeed() * 2.7f);
	}

	//Add some gems to the level
	x = 0; y = 0; z = 1200;
	for(int i = 0; i < 3; i++){
		y = (irr::f32)(rand() % 40 + 1) - 20;
		BronzeGem *gem = new BronzeGem(irr::core::vector3df(x, y, z), smgr);
		gem->moveAwayFromPlayer(true, Game::getCurrentPlayer()->getMovementSpeed());
		z += (rand() % 3000 + 1000) + (player->getMovementSpeed() * 2.7f);
	}

	//Add some asteroids to the level
	x = 0; y = 0; z = 2000;
	for(int i = 0; i < 14; i++){
		y = (irr::f32)(rand() % 70 + 1) - 35;
		StaticObject *Obsticle = new StaticObject(irr::core::vector3df(x, y, z), "Assets/Environment/Asteroid/Asteroid1.obj", "Assets/Environment/Asteroid/AsteroidTextureA.jpg", device->getSceneManager(), true);
		Obsticle->moveAwayFromPlayer(true, Game::getCurrentPlayer()->getMovementSpeed());
		z += (rand() % 500 + 500) + (player->getMovementSpeed() * 2.7f);
	}

	phase2Loaded = true;
}
开发者ID:ThisisJaws,项目名称:Pi,代码行数:54,代码来源:IceWorld.cpp


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