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


C++ Enemy类代码示例

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


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

示例1: Update

void EnemyManager::Update()
{
	for (int i = 0; i < m_enemies->size(); i++)
	{
		Enemy* e = m_enemies->at(i);
		if (e->hp < 0)
		{
			delete e;
			m_enemies->erase(m_enemies->begin() + i);
			i--;
			continue;
		}
		e->Update();
	}
}
开发者ID:AdrianPetrosanu,项目名称:OpenGLTest,代码行数:15,代码来源:EnemyManager.cpp

示例2: Enemy

//================================================================================
// 生成処理
//================================================================================
Enemy* Enemy::create(const Vec2& pos,ENEMY_KIND nKindEnemy)
{
    // インスタンスの生成
    Enemy* pEnemy = new Enemy();

    // メンバ変数の代入
    pEnemy->m_pos = pos;
    pEnemy->m_nEnemyKind = nKindEnemy;
    

    // 初期化
    pEnemy->init();
    
    return pEnemy;
}
开发者ID:JunMaru,项目名称:BrushToothGame,代码行数:18,代码来源:Enemy.cpp

示例3: testEnemySet

	// Tests for Enemy
	void testEnemySet(void) {
		setUp();

		Enemy *enemy = new Enemy();
		enemy->set(*tileSet, 0, 0);
		Sprite * testSprite = new Sprite();
		testSprite->setTexture(*tileSet);
		testSprite->setTextureRect(IntRect(0, 0, 1, 1));

		TS_ASSERT_DELTA(enemy->dx, ENEMY_SPEED, 0.01);
		TS_ASSERT(enemy->life);

		delete enemy;
		breakDown();
	}
开发者ID:laazer,项目名称:portalpp,代码行数:16,代码来源:PortalTestSuite.hpp

示例4: Enemy

vector<Enemy*> CharacterFactory::parseXML(string xmlPath) {
	// Read from file
	XMLDocument doc;
	doc.LoadFile(xmlPath.c_str());
	// Text is just another Node to TinyXML-2. The more
	// general way to get to the XMLText:
	XMLElement *node = doc.FirstChildElement("enemies")->FirstChildElement("enemy")->ToElement();
	for (node; node; node = node->NextSiblingElement())
	{
		Enemy* character = new Enemy();
		character->parseXMLElement(node);
		characters.push_back(character);
	}
	return characters;
}
开发者ID:spboom,项目名称:CPP_EindOpdracht,代码行数:15,代码来源:CharacterFactory.cpp

示例5:

/**
 * \brief Returns whether the hero can be hurt by an attacker in this state.
 * \param attacker an attacker that is trying to hurt the hero
 * (or nullptr if the source of the attack is not an enemy)
 * \return true if the hero can be hurt in this state
 */
bool Hero::RunningState::can_be_hurt(Entity* attacker) const {

  if (phase == 0) {
    // Preparing to run.
    return true;
  }

  if (attacker != nullptr && attacker->get_type() == EntityType::ENEMY) {
    // TODO move get_can_hurt_hero_running to Entity.
    Enemy* enemy = static_cast<Enemy*>(attacker);
    return enemy->get_can_hurt_hero_running();
  }

  return false;
}
开发者ID:Codex-NG,项目名称:solarus,代码行数:21,代码来源:RunningState.cpp

示例6: HandleBullets

// Public for enemy to call - handle bullet collision and damage applying
void Player::HandleBullets(Enemy& e)
{
	if (!e.IsSpawned())
		return;
	for (int i = 0; i < m_Bullets.size(); i++)
	{
		if (e.DetectBulletCollision(m_Bullets[i]))
		{
			e.ApplyDamage(2);
			m_Bullets.erase(m_Bullets.begin() + i);
			i--;
			continue;
		}
	}
}
开发者ID:jblakeLincoln,项目名称:jframe-megaman,代码行数:16,代码来源:Player.cpp

示例7: Enemy

Enemy* Enemy::nodeWithTheGame(HelloWorld* game)
{
	Enemy *pRet = new Enemy();
	if (pRet && pRet->initWithTheGame(game))
	{
		pRet->autorelease();
		return pRet;
	}
	else
	{
		delete pRet;
		pRet = NULL;
		return NULL;
	}
}
开发者ID:Kurukshetran,项目名称:Cocos2dxGame,代码行数:15,代码来源:Enemy.cpp

示例8: ReadXmlEnemyData

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

示例9: Enemy

Enemy* Enemy::create ( KDuint uType )
{
	Enemy*  pRet = new Enemy ( );

	if ( pRet && pRet->init ( uType ) )
	{
		pRet->autorelease ( );
	}
	else
	{
		CC_SAFE_DELETE ( pRet );
	}

	return pRet;
}
开发者ID:mcodegeeks,项目名称:OpenKODE-Framework,代码行数:15,代码来源:Enemy.cpp

示例10: enemyBossUpdate

//////// Boss moves down into game screen ////////
//////// then begins its attack run       ////////
void AI::enemyBossUpdate(Enemy &enemy, const float dt)
{
	// Move into game screen
	if (enemy.getPosition() < D3DXVECTOR3(0.0f, 20.0f, 0.0f)) // TODO: Modify for constant Y position value
	{
		D3DXVECTOR3 vel = D3DXVECTOR3(0.0f, -5.0f, 0.0f);
		enemy.setVelocity(vel);
		// Uncomment if needed
		//enemy.setPosition(enemy.getPosition() += vel * dt);
	}
	else
	{
		// Begin attack run
		// Fire bullets
		float bFireRate = enemy.getBulletFireRate();
		enemy.setBulletFireRate(bFireRate -= dt);
		if (bFireRate <= 0.0f)
		{
			float x = -20.0f;
			for (int i = 0; i < 4; i++)
			{
				enemy.fireBullet(D3DXVECTOR3(x, -20.0f, 0.0f));
				x += 10.0f;
			}

			enemy.setBulletFireRate(1.0f);
		}

		// Fire missiles
		float missFireRate = enemy.getMissileFireRate();
		enemy.setMissileFireRate(missFireRate -= dt);
		if (missFireRate <= 0.0f)
		{
			enemy.fireMissile(D3DXVECTOR3(0.0f, -20.0f, 0.0f));
			enemy.setMissileFireRate(10.0f);
		}

		// Fire mines
		// Cannot specify where to drop mine
		// Mines are listed as a pickup, are they intended to be picked up by the player?
		/*float mineFireRate = enemy.getMineFireRate();
		enemy.setMineFireRate(mineFireRate -= dt);
		if (mineFireRate <= 0.0f)
		{

		}*/
	}
}
开发者ID:mblake90,项目名称:GSP420EngineDemo,代码行数:50,代码来源:AI.cpp

示例11: Enemy

void LevelGenerator::spawnEnemy(core::Siika2D *siika, int xPos, int yPos)
{
	Enemy *e;
	bool fly = false;
	if (lrand48() % 3 == 0)
		fly = true;

	int frames = 0;
	int speed = 200;

	if (fly)
	{
		if (generatorName == "castle")
			e = new Enemy("sprite_mikucopter.png");
		else if (generatorName == "plains")
			e = new Enemy("sprite_noodles.png");
		else
		{
			e = new Enemy("sprite_shibat.png");
			yPos += 80;
		}
	}
	else
	{
		if (generatorName == "castle")
			e = new Enemy("sprite_meido.png");
		else if (generatorName == "forest")
			e = new Enemy("sprite_shimapanda.png");
		else
		{
			e = new Enemy("sprite_gigapuddi.png", true);
			speed = 100;
			frames = 8;
		}
	}

	e->init(siika, 0, frames, speed);
	e->xPos = xPos;
	e->yPos = yPos;
	e->yLevel = e->yPos;

	if (fly)
		e->flies = true;

	e->go->move(glm::vec2(e->xPos, e->yPos));

	enemies.push_back(e);
}
开发者ID:Ranquil,项目名称:Ushiko,代码行数:48,代码来源:LevelGenerator.cpp

示例12: Enemy

Enemy* Enemy::create(CCPoint position, const char* fileName)
{
	//エネミー生成
	Enemy* enemy = new Enemy();
	if (enemy)
	{
        enemy->initEnemy(position, fileName);
		enemy->autorelease();
		GAME::getInstance()->addChild(enemy, kTag_Enemy, kOrder_Enemy);
		return enemy;
	}
	//autoreleaseを使用しているため、deleteの代わりに使用、メモリを開放
	//何度も生成しないようにガードをかける
	CC_SAFE_DELETE(enemy);
	return NULL;
}
开发者ID:Nadd3564,项目名称:2DActionPuzzleGame,代码行数:16,代码来源:Enemy.cpp

示例13: Fire

// Attempt to fire at enemy; return true if destroyed
bool Tower::Fire(Enemy &enemy,	vector <Bullet> &Shots)
{
	if (reloadTime <= 0)
	{
		double dx, dy, towerX, towerY, enemyX, enemyY;
		towerX = (gridX + .5)*TILESIZE;
		towerY = (gridY + .5)*TILESIZE;
		enemyX = enemy.x + .5*TILESIZE;
		enemyY = enemy.y + .5*TILESIZE;
		dx = enemyX - towerX;
		dy = enemyY - towerY;
		if (dx*dx + dy*dy <= range*range)
		{
			double angle = atan2(dy, dx)/M_PI + 1;
			direction = (int)((4*(angle))+6.5)%8;
			reloadTime+=1./rate;
			angle = (direction+2)*M_PI/4;
			int bulletX = towerX - TILESIZE*cos(angle)/2;
			int bulletY = towerY - TILESIZE*sin(angle)/2;
			Shots.push_back(Bullet(bulletX, bulletY,
						enemyX, enemyY));
			if (enemy.damage(power))
			{
				return true;
			}
		}
	}

	return false;
};
开发者ID:siruilu,项目名称:FundCompIIFinal,代码行数:31,代码来源:Tower.cpp

示例14: update

	double Player::update(const Enemy& enemy) {
		vec3 el = enemy.getLoc();
		vel += (el-loc).norm() * 6000 / (pow((el-loc).abs(),1.83)+80);

		if((el-loc).abs() < 250) return 0.005;
		return 0;
	}
开发者ID:jamespayor,项目名称:CubeWorld,代码行数:7,代码来源:Agent_Player.cpp

示例15: notify_collision_with_enemy

/**
 * \brief This function is called when an enemy's sprite collides with a sprite of this entity.
 * \param enemy the enemy
 * \param enemy_sprite the enemy's sprite that overlaps the hero
 * \param this_sprite the arrow sprite
 */
void Hookshot::notify_collision_with_enemy(
    Enemy& enemy, Sprite& enemy_sprite, Sprite& /* this_sprite */) {

  if (!overlaps(get_hero())) {
    enemy.try_hurt(EnemyAttack::HOOKSHOT, *this, &enemy_sprite);
  }
}
开发者ID:akimi634,项目名称:solarus,代码行数:13,代码来源:Hookshot.cpp


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