本文整理汇总了C++中Hero::die方法的典型用法代码示例。如果您正苦于以下问题:C++ Hero::die方法的具体用法?C++ Hero::die怎么用?C++ Hero::die使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Hero
的用法示例。
在下文中一共展示了Hero::die方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: verifyWinLose
/**************************************************************************************
VERIFY WIN/LOSE CONDITION
**************************************************************************************/
void verifyWinLose() {
if(score_points >= WIN_CONDITION) {
end_game = GL_TRUE;
}
if(end_game) {
game_speed = 0.0f;
move_text(score_txtLabel, -0.15, 0.2f);
if(score_points >= WIN_CONDITION) {
score = "You WIN!";
hero.win(dt);
} else {
score = "You LOSE!";
if(jumps == 0) {
hero.setVelocity(60.0f);
jumps++;
}
for(int i=0; i<NUMBER_OF_MONSTERS; i++)
monster[i].stop = 0.0f;
hero.die(dt);
if(camera_loops < 1 && hero.died) {
camera.setSpeedRotation(3.0f);
camera.rotation360();
camera_loops++;
}
}
}
}
示例2: update
void Shot::update(){
if (++mLife > 180){
setCollided(true);
}
if (touchesDangerousTile()){
setCollided(true);
}
if(hasCollided()){
if (--mCollidedTimer < 0){
remove();
//remove
}
return;
}
// move
int cur_x = getPosition().x;
int cur_y = getPosition().y;
int floor_y, edge_x;
int bumps;
/*
floor_y= cur_y+getHalfSize().y+5;
if (mFacingDirection == Direction_Left){
edge_x=cur_x-getHalfSize().x;
} else {
edge_x=cur_x+getHalfSize().x;
}
*/
if(mGravity[mShotType] == ShotType_Bullet){
setVelocity(float2(mInitialVelocity[mShotType].x*getDirection(),mInitialVelocity[mShotType].y));
} else {
setVelocity(float2(mInitialVelocity[mShotType].x*getDirection(),mInitialVelocity[mShotType].y+GRAVITY*mLife));
}
//setVelocity(float2(12.0f,.0f));
bumps=moveWithCollision();
if((bumps & Direction_Left) != 0 || (bumps & Direction_Right) != 0 || (bumps & Direction_Up) != 0|| (bumps & Direction_Down) != 0 ){
setCollided(true);
if (mShotType == ShotType_GravityGrenade || mShotType == ShotType_Fireball) { Sound::playSample("data/sounds/grenadeexplode.wav"); }
}
if(!mHurtPlayer){
std::vector<Entity*> collidedEntity = mRoom->checkEntitiesForCollision(this);
if(collidedEntity.size() > 0){
setCollided(true);
if (mShotType == ShotType_GravityGrenade || mShotType == ShotType_Fireball) { Sound::playSample("data/sounds/grenadeexplode.wav"); }
for(int i=0;i<collidedEntity.size();i++){
attack(collidedEntity[i]);
}
}
} else {
Hero* h = mRoom->getHero();
Entity::CollisionRect cr= h->getCollisionRect();
if(Collides(getCollisionRect(),cr)){
setCollided(true);
if (mShotType == ShotType_GravityGrenade || mShotType == ShotType_Fireball) { Sound::playSample("data/sounds/grenadeexplode.wav"); }
if(mShotType == ShotType_Fireball || mShotType == ShotType_Bullet){
h->die();
return;
}
if(mShotType == ShotType_GravityGrenade){
attack(h);
return;
}
}
}
mFrame++;
}