// 移動 bool CPrepareNishi::Move() { // 移動範囲、速度 static const float MaxLX=150+Width/2, MaxRX=490-Width/2, MaxTY=20+Height/2, MaxBY=460-Height/2, SPEED =6,LOW_SPEED =2; //消滅判定処理 if(live_count<=0) { new CNishi(X,Y, m_BombNum, m_LifeNum); return false; }else{ --live_count; } // キーボードの入力 KEYSTATE key; Game->input->GetAllState(&key); // 移動 if(!key.SHIFT) { if (key.RIGHT){ X+=SPEED; }else if (key.LEFT) { X-=SPEED; } if (key.UP){ Y-=SPEED; }else if (key.DOWN){ Y+=SPEED; } }else{ if (key.RIGHT){ X+=LOW_SPEED; }else if (key.LEFT) { X-=LOW_SPEED; } if (key.UP){ Y-=LOW_SPEED; }else if (key.DOWN){ Y+=LOW_SPEED; } } //アイテムの取得判定 for(CTaskIter i(Game->ItemList);i.HasNext();) { CItem *item =(CItem*)i.Next(); if(HitCircle(item,X,Y,23)) { item->SetXYSpeed(X,Y,5.0f); } if(HitCircle(item)) { Game->sound[7]->Play(); Game->score->AddScore((unsigned)item->GetScore()); i.Remove(); } } // 移動範囲の制限 if (X<MaxLX) { X=MaxLX; }else if (MaxRX<X){ X=MaxRX; } if (Y<MaxTY){ Y=MaxTY; }else if (MaxBY<Y){ Y=MaxBY; } color =D3DCOLOR_ARGB(0xf0,rand()%256,rand()%256,rand()%256); ++anime_count; if(anime_count>=10) { ++anime; anime_count =0; if(anime>4) anime =1; } return true; }
// 移動 bool CNishi::Move() { // 移動範囲、速度 static const float MaxLX=150+Width/2, MaxRX=490-Width/2, MaxTY=20+Height/2, MaxBY=460-Height/2, SPEED =6,LOW_SPEED =2; // キーボードの入力 prevbomb_input =key.X; Game->input->GetAllState(&key); // 移動 if(!key.SHIFT) { if (key.RIGHT){ X+=SPEED; }else if (key.LEFT) { X-=SPEED; } if (key.UP){ Y-=SPEED; }else if (key.DOWN){ Y+=SPEED; } }else{ if (key.RIGHT){ X+=LOW_SPEED; }else if (key.LEFT) { X-=LOW_SPEED; } if (key.UP){ Y-=LOW_SPEED; }else if (key.DOWN){ Y+=LOW_SPEED; } } //ボムの発射 if(!prevbomb_input && bomb_count<=0 && m_BombNum>0 && key.X) { bomb_count =100; --m_BombNum; Game->SetHUD(m_LifeNum,m_BombNum); new CMyBomb(X,Y); } else if(bomb_count>0) { --bomb_count; } //弾の発射 if(!key.Z){ shot_count =20; laser_count =20; laser_num =0; } else { if(!key.SHIFT) { laser_num =0; NormalShot(2); }else{ NormalShot(0); NormalLaser(8); } } //当たり判定処理 if(bomb_count<=0) { if(live_count<=0) { for(CTaskIter i(Game->EnemyBulletList);i.HasNext();) { CEBullet *bullet =(CEBullet*)i.Next(); if(HitCircle(bullet)) { Game->sound[1]->Play(); Game->MyLaserList->DeleteTask(); if(m_LifeNum>=0) { --m_LifeNum; } Game->SetHUD(m_LifeNum,m_BombNum); new CMyCrash(X,Y, m_BombNum, m_LifeNum); return false; } } for(CTaskIter i(Game->EnemyList);i.HasNext();) { CEnemy *enemy =(CEnemy*)i.Next(); if(HitCircle(enemy)) { Game->sound[1]->Play(); Game->MyLaserList->DeleteTask(); if(m_LifeNum>=0) { --m_LifeNum; } Game->SetHUD(m_LifeNum,m_BombNum); new CMyCrash(X,Y, m_BombNum, m_LifeNum); return false; } } }else{ --live_count; } } //アイテムの取得判定 for(CTaskIter i(Game->ItemList);i.HasNext();) { CItem *item =(CItem*)i.Next(); if(HitCircle(item,X,Y,18)) { item->SetXYSpeed(X,Y,5.0f); } if(HitCircle(item)) { Game->sound[7]->Play(); Game->score->AddScore((unsigned)item->GetScore()); i.Remove(); } } // 移動範囲の制限 if (X<MaxLX) { X=MaxLX; }else if (MaxRX<X){ X=MaxRX; } if (Y<MaxTY){ Y=MaxTY; }else if (MaxBY<Y){ Y=MaxBY; } ++anime_count; if(anime_count>=10) { ++anime; anime_count =0; if(anime>4) anime =1; } return true; }