void CEnemyBase::Damaged() { // 残り耐久度を1減らす hardness--; if(hardness == 0){ CSound *se = new CSound(*(CSound*)FindItemBox("explode1")); se->EnableDeleteByEnd(); se->Play(); // 爆発処理を追加 AppendObject(new CExplosion(x, y), EXPLOSION_PRIORITY, true); // 自身を削除 RemoveObject(this); } }
void CEnemy3::Damaged() { hardness--; if(hardness == 0){ // 10個の爆炎をランダムで拡散させる for(int i = 0; i < 10; i++){ float angle = d2r((float)(36 * i)); float size = 0.5f + 2.0f * (float)rand() / (float)(RAND_MAX + 1); float speed = 1.0f + 5.0f * (float)rand() / (float)(RAND_MAX + 1); AppendObject(new CExplosion(x, y, size, angle, speed), EXPLOSION_PRIORITY, true); } CSound *se = new CSound(*(CSound*)FindItemBox("explode2")); se->EnableDeleteByEnd(); se->Play(); AppendObject(new CPowerupItem(x, y), PLAYER_PRIORITY, true); RemoveObject(this); } }
bool CBoss::ActionDestroy() { frame++; if(frame < 500){ // 500フレーム目まではボス周辺でランダムに爆炎を発生させる if(frame % 5 == 0){ float xx = x + (float)(rand() % 500 - 250); float yy = y + (float)(rand() % 300 - 150); float sz = 1.0f + 2.0f * (float)rand() / (float)RAND_MAX; AppendObject(new CExplosion(xx, yy, sz, 0.0f, 0.0f), EXPLOSION_PRIORITY, true); } y += 0.2f; if(frame % 15 == 0){ ((CSound*)FindItemBox("explode1"))->Play(); } return false; }else{ // 500フレーム目で大爆発を起こす float xx, yy, a, s, z; for(int i = 0; i < 50; i++){ xx = x + (float)(rand() % 100 - 50); yy = y + (float)(rand() % 100 - 50); a = atan2f(x - xx, yy - y); s = 5.0f + 10.0f * (float)rand() / (float)RAND_MAX; z = 3.0f + 8.0f * (float)rand() / (float)RAND_MAX; AppendObject(new CExplosion(xx, yy, 2.0f, a, s), EXPLOSION_PRIORITY, true); } CSound *se = new CSound(*(CSound*)FindItemBox("explode3")); se->EnableDeleteByEnd(); se->Play(); return true; } }