本文整理汇总了C++中Enemy::fireMissile方法的典型用法代码示例。如果您正苦于以下问题:C++ Enemy::fireMissile方法的具体用法?C++ Enemy::fireMissile怎么用?C++ Enemy::fireMissile使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Enemy
的用法示例。
在下文中一共展示了Enemy::fireMissile方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: sin
void AI::enemy2Update(Enemy &enemy, const float dt)
{
//this will represent the max distance the enemy can moe up and down
float maxAmplitude;
//create a vector to change for the new enemy position
D3DXVECTOR3 tempVel = enemy.getPosition();
//increment the y-position to follow a sine curve
tempVel.y = maxAmplitude * sin(dt * 0.5f * PI);
//increment the Xposition by the EnemySpeed
tempVel.x = tempVel.x += ENEMY_SPEED;
//normalize the vector
D3DXVec3Normalize(&tempVel, &tempVel);
tempVel *= ENEMY_SPEED;
enemy.setVelocity(tempVel);
// Check if enemy should fire a missile
float missFireRate = enemy.getMissileFireRate();
enemy.setMissileFireRate(missFireRate -= dt);
if (missFireRate <= 0.0f)
{
enemy.fireMissile(D3DXVECTOR3(0.0f, -5.0f, 0.0f)); // TODO: Modify for a fixed missile speed constant
enemy.setMissileFireRate(ENEMY_MISSILE_FR);
}
}
示例2: 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)
{
}*/
}
}