本文整理汇总了C++中Enemy::getHealth方法的典型用法代码示例。如果您正苦于以下问题:C++ Enemy::getHealth方法的具体用法?C++ Enemy::getHealth怎么用?C++ Enemy::getHealth使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Enemy
的用法示例。
在下文中一共展示了Enemy::getHealth方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: checkDeath
/**
* If a player, enemy, or bullet has less than 1 health, it is frigging DEAD
*/
void checkDeath() {
if(p.getHealth() < 1) {
game_running = false;
}
std::vector<Enemy*>::iterator eIter = enemies.begin();
while(eIter != enemies.end()) {
Enemy * eni = *eIter;
if(eni->getHealth() < 1) {
eIter = enemies.erase(eIter);
} else {
++eIter;
}
}
std::vector<Bullet*>::iterator bIter = bullets.begin();
while(bIter != bullets.end()) {
Bullet * b = *bIter;
if(b->getHealth() < 1) {
bIter = bullets.erase(bIter);
p.setBullets(bullets);
} else {
++bIter;
}
}
// Check to see if a bullet is "off screen, in which case it DIES"
bIter = bullets.begin();
while(bIter != bullets.end()) {
Bullet * b = *bIter;
if(b->getX() < 0 || b->getX() > GAME_WIDTH || b->getY() < 0 || b->getY() > GAME_HEIGHT) {
bIter = bullets.erase(bIter);
p.setBullets(bullets);
} else {
++bIter;
}
}
}
示例2: update
void PsiBlob::update(){
if(m_Health <= 0 && !ContainsFlags(m_UnitStatus,Dead)){
die();
}
else if(!ContainsFlags(m_UnitStatus,Dead)){
if(getTarget()){
if(m_Target->getHealth() <= 0){
m_Target = NULL;
stop();
}
else if(getTarget()->getCurrentTile() != getDestinationTile()){
setDestinationTile(getTarget()->getCurrentTile());
}
}
moveLerp();
Enemy* enemy;
if((enemy = BlobGame::instance()->enemyOnTile(getCurrentTile()))){
enemy->hit(enemy->getHealth());
}
updateAbilities();
}
}