本文整理汇总了C++中Enemy::dropMine方法的典型用法代码示例。如果您正苦于以下问题:C++ Enemy::dropMine方法的具体用法?C++ Enemy::dropMine怎么用?C++ Enemy::dropMine使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Enemy
的用法示例。
在下文中一共展示了Enemy::dropMine方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: cos
void AI::enemy3Update(Enemy &enemy, const float dt)
{
//create the radius if the circle you want the enemy to move
float radius = 5.0f;
//this will represent the angle in the circle the enemy will be in
float angle = 0.0f;
//set the angle to the current time settings so it continous to incrememnt
//as the enemy is on the screen
float angle = dt;
//create a vector that represents the enemies current position
D3DXVECTOR3 tempVel = enemy.getPosition();
//set the enemy position as the center of the circle
D3DXVECTOR3 origin = tempVel;
//make the new enemy position depending on sin and cos curves
tempVel.x = origin.x + cos(angle) * radius;
tempVel.y = origin.y + sin(angle) * radius;
D3DXVec3Normalize(&tempVel, &tempVel);
tempVel *= ENEMY_SPEED;
enemy.setVelocity(tempVel);
// Check if enemy should drop a mine
float mineFireRate = enemy.getMineFireRate();
enemy.setMineFireRate(mineFireRate -= dt);
if (mineFireRate <= 0.0f)
{
enemy.dropMine();
enemy.setMineFireRate(ENEMY_MINE_FR);
}
}