void gamestart() { shot_used2[0] = false; shot_used3[0] = false; shot_used2[1] = false; shot_used3[1] = false; game_startflag = true; if(loadbgm_flag == false) { PlaySoundMem(start_m,DX_PLAYTYPE_BACK); bgm[0] = LoadSoundMem("media\\bgm2.ogg"); bgm[1] = LoadSoundMem("media\\bgm3.ogg"); bgm[3] = LoadSoundMem("media\\bgm4.ogg"); bgm[5] = LoadSoundMem("media\\bgm5.ogg"); bgm[2] = LoadSoundMem("media\\bgm6.ogg"); bgm[4] = LoadSoundMem("media\\bgm7.ogg"); WaitTimer(2000); loadbgm_flag = true; } else { PlaySoundMem(start_m,DX_PLAYTYPE_NORMAL); } jiki_x = 304; }
void Pshot::HitCheck() { for(auto &shot : Ashot) { if (!shot->f_exist) continue; const bool IS_HIT = ( Game::IsHitBoss(shot->x_pos, shot->y_pos, shot->atk) || EnemyMng::IsHit(shot->x_pos, shot->y_pos, shot->atk) ); if (IS_HIT) shot->f_exist = false; if (IS_HIT) PlaySoundMem(hs_hit, DX_PLAYTYPE_BACK); if (IS_HIT) effect->PlayAnime(shot->x_pos, shot->y_pos); } // ------------------------------------------------------------------------------- for (auto &shot : Bshot) { if (!shot->f_exist) continue; const bool IS_HIT = (Game::IsHitBoss(shot->x_pos, shot->y_pos, shot->atk) || EnemyMng::IsHit(shot->x_pos, shot->y_pos, shot->atk)); if (IS_HIT) shot->f_exist = false; if (IS_HIT) PlaySoundMem(hs_hit, DX_PLAYTYPE_BACK); if (IS_HIT) effect->PlayAnime(shot->x_pos, shot->y_pos); } // ------------------------------------------------------------------------------- for (auto &shot : Cshot) { if (!shot->f_exist) continue; const bool IS_HIT = (Game::IsHitBoss(shot->x_pos, shot->y_pos, shot->atk) || EnemyMng::IsHit(shot->x_pos, shot->y_pos, shot->atk)); if (IS_HIT) shot->f_exist = false; if (IS_HIT) PlaySoundMem(hs_hit, DX_PLAYTYPE_BACK); if (IS_HIT) effect->PlayAnime(shot->x_pos, shot->y_pos); } }
//ショット描画 bool drawshot() { for(int i = 0;i<maxshot;i++) { if(shot_used[i] == true) { shot_s[i].x = jiki_x; shot_s[i].y = jiki_y; PlaySoundMem(se_shot,DX_PLAYTYPE_BACK); shot_kaisuu++; shot_used[i] = false; shot_used2[i] = true; if(change_jikiflag == false) { change_shotflag[i] = false; } else { change_shotflag[i] = true; } } if(shot_used2[i] == true) { shot_s[i].y -= 7; } if(shot_used3[i] == true) { if(change_shotflag[i] == false) { DrawGraph((int)shot_s[i].x,(int)shot_s[i].y,g_shot,TRUE); } else { DrawGraph((int)shot_s[i].x,(int)shot_s[i].y,g_shot2,TRUE); } } if(shot_s[i].y <= -26) { shot_used2[i] = false; shot_used3[i] = false; shot_s[i].y = 0; if(combo >= 4) { PlaySoundMem(se_combo_miss,DX_PLAYTYPE_BACK); } combo = 0; } } return true; }
//ショットの判定 void shot_hantei() { for(int i = 0;i<ball_kazu;i++) { for(int j = 0;j<maxshot;j++) { if(shot_used3[j] == true) { if(ball_pos_x[i]-16 < shot_s[j].x+28 && ball_pos_y[i]-16 < shot_s[j].y+20 && shot_s[j].x+5 < ball_pos_x[i]+16 && shot_s[j].y+2 < ball_pos_y[i]+16) { first_shotflag = true; vecter[i].y = -1; shot_used2[j] = false; shot_used3[j] = false; if((change_ballflag[i] == false && change_shotflag[j] == true ||change_ballflag[i] == true && change_shotflag[j] == false) && shot_missflag[i] == false) { PlaySoundMem(se_hit2,DX_PLAYTYPE_BACK); combo += 1; if(combo >= 4) { score += 200+(level*80)+(combo*100); } else { score += 200+(level*80); //score += 1999999999; } } else { PlaySoundMem(se_hit,DX_PLAYTYPE_BACK); score += 100+(level*40); combo = 0; sky_combo = 10; if(level >= 10 && c78_flag == true) { shot_missflag[i] = !shot_missflag[i]; } } change_ballflag[i] = !change_ballflag[i]; } } } } }
int TitleUpdate(int startPushHandle, int sceneFrame) { int Pad = GetJoypadInputState( DX_INPUT_KEY_PAD1); if (TitleSelectCount <= 0 && TitleChangeFlg == 0 && (Pad & PAD_INPUT_4) ) { PlaySoundMem(startPushHandle, DX_PLAYTYPE_BACK); TitleChangeFlg = 1; } if (TitleSelectCount <= 0 && (Pad & PAD_INPUT_L)) { StaffRollCount = 0; sceneFrame = 6; TitleSelectCount = 20; } if (TitleChangeFlg == 1) { if (TitleChangeCount >= 120) { sceneFrame = 1; TitleChangeCount = 0; TitleChangeFlg = 0; TitleSelectCount = 20; } else { TitleChangeCount++; } } if (sceneFrame == 0 && TitleSelectCount > 0) { TitleSelectCount--; } return sceneFrame; }
int Boss::Colision(Character &c, int damagesound){ for (int i = 0; i < SNUM; i++){ if (c.shot[i].flag){ HitPolyDim = MV1CollCheck_Sphere(graph, -1, VGet(c.shot[i].x, c.shot[i].y, c.shot[i].z), 2.0f); if (HitPolyDim.HitNum >= 1){ life --; c.shot[i].flag = 0; for (int i = 0; i < 16; i++){ if (HitEffectFlag[i] == 0){ HitEffectPosition[i] = HitPolyDim.Dim->HitPosition; HitEffectFlag[i] = 1; } } flag |= HIT; PlaySoundMem(damagesound, DX_PLAYTYPE_BACK); } } } for (int i = 0; i < BSNUM; i++){ if (bs[i].flag){ float d; d = sqrt((bs[i].x - c.GetX())*(bs[i].x - c.GetX())) + sqrt((c.GetZ() - bs[i].z)*(c.GetZ() - bs[i].z)); d = sqrt(d * d + (c.GetY() - bs[i].y) * (c.GetY() - bs[i].y)); if (d < 4){ c.SetLife(c.GetLife() - 1); bs[i].flag = 0; bs[i].z = 100; } } } return 1; }
//音楽を流さなくてもこの関数を読み込み推奨 void PlayBGM( int Number ){ //処理を一回だけ読み込む(なお指定されたnumberの音楽がなければこの処理は前の音楽が流れ続ける) if(CheckSoundMem(Music[Number].Music)==0){ for(int i=0; i<AllBGM; i++ )StopSoundMem( Music[i].Music ) ; PlaySoundMem( Music[Number].Music, DX_PLAYTYPE_LOOP ) ; } }
void Message::magic_attack(const char* chant_magic, cint magic_sound_handle) { this->window_box(); if (this->print_in_kanji) DrawFormatString(this->message_window.x + 5, this->message_window.y + 5, this->message_window.string_color, "%sは%sを唱えた!", this->attacker.c_str(), chant_magic); else DrawFormatString(this->message_window.x + 5, this->message_window.y + 5, this->message_window.string_color, "%sは%sをとなえた!", this->attacker.c_str(), chant_magic); ScreenFlip(); PlaySoundMem(magic_sound_handle, DX_PLAYTYPE_NORMAL); }
//効果音を発生 void sound_play() { for(int i=0; i<SE_MAX; i++) { if(se_flag[i]==1) { PlaySoundMem(se[i], DX_PLAYTYPE_BACK); } } }
//スカイフィッシュの判定 void shot_sky() { for(int i = 0;i<maxshot;i++) { if(sky.x+1 < shot_s[i].x+28 && sky.y+10 < shot_s[i].y+20 && shot_s[i].x+5 < sky.x+63 && shot_s[i].y+2 < sky.y+22 && sky_used == true && shot_used3[i] == true) { first_shotflag = true; shot_used2[i] = false; shot_used3[i] = false; sky_used = false; sky.x = 640; sky_sound = false; score += 1500*(level+combo); StopSoundMem(se_chance); PlaySoundMem(se_sky_shot,DX_PLAYTYPE_BACK); for(int j=0;j<ball_kazu;j++) { shot_missflag[j] = false; } } } }
//一回だけ再生 void Sound::playone(std::string name){ auto &a = get().handlemap[name]; if (a.play_cool <= 0){ PlaySoundMem(get().handle(name), DX_PLAYTYPE_BACK); a.play_cool = a.play_rate; } }
void CShootingScene::InitScene(void) { m_shotid = LoadGraph(_T("Image\\弾00.png")); m_Player.SetImageID(LoadGraph(_T("Image\\吹雪.png"))); m_Player.m_Speed = 3; m_Player.SetCenterX(200); m_Player.SetCenterY(400); m_Player.m_pEquipment.m_ShotInterval = 100; m_Player.m_pEquipment.m_ShotSpeed = 10; m_BackGroundImageLeft.SetImageID( LoadGraph(_T("Image\\海.png"))); m_BackGroundImageRight.SetImageID(LoadGraph(_T("Image\\背景.png"))); m_BackGroundImageRight.m_x = 400; //バックグラウンド再生 LoadBackgroundMusic(_T("Sound\\BGM\\rinkai.wav")); ChangeVolumeSoundMem(50, m_BackgroundMusic); //音量調節 PlaySoundMem(m_BackgroundMusic, DX_PLAYTYPE_LOOP,TRUE); m_Enemy.SetImageID(LoadGraph(_T("Image\\ボス258.png"))); m_Enemy.SetCenterX(200); m_Enemy.SetCenterY(130); m_h.SetImageID(LoadGraph(_T("Image\\吹雪立ち絵.png"))); m_h.m_x = 450; m_h.m_y = 120; }
void MessageWindow::Update() { BaseWindow::Update(); // テキストが空なら飛ばす if (!MessagesAreEmpty) { // 今のメッセージが表示が終わっている場合の処理 if (ShowingIsFinish) { // エンターキーが押されたら、次のメッセージに if (Keyboard::getinstance()->Keyboard_Get(KEY_INPUT_RETURN) % 20 == 1) { MessagesAreEmpty = GoNextText(); } // 今のメッセージが表示が終わってない場合の処理 } else { ++CharShowCount; // エンターキーが押されたら、メッセージを全部表示 if (Keyboard::getinstance()->Keyboard_Get(KEY_INPUT_RETURN) % 20 == 1) { NowText = Texts.front(); } // 次の文字を表示 if (CharShowCount >= CharShowWait && NowText.size() != Texts.front().size()) { // 最初の3文字を表示するとき音を鳴らす if (ShowingNumber < 3) { PlaySoundMem(NextCharSE, DX_PLAYTYPE_BACK); } NowText = Texts.front().substr(0, ShowingNumber + 1); CharShowCount = 0; ++ShowingNumber; } // 現在のメッセージが表示終わっていたら、フラグを立てる ShowingIsFinish = NowText == Texts.front(); } } }
void FallingObject::Hit() { if(!once){ PlaySoundMem(sound_h, DX_PLAYTYPE_BACK, true); exist = false; once = true; //score.Hit(); } }
// 足座標・踏んだものチェック void GameRoad::chReg(SPRITE *sp) { // 足元 reg.x = sp->x; reg.y = sp->y + sp->h - 4; if(reg.y < 0) { reg.y = 0; } int c = 0; int _x, _y; static POINT now; int i; SPRITE *sp2 = &spd[RO_SP_BR_R1]; if(reg.x < roadx[RO_X_CNT-1]) { now.x = -1; now.y = -1; return; } // Goal if(reg.x >= roadx[0]+sp2->w) { cond = RO_END; now.x = -1; now.y = -1; return; } // 現在のx位置を算出 for (i=0; i<RO_X_CNT; i++) { if (reg.x >= roadx[i] && reg.x < roadx[i]+sp2->w) { break; } } _x = i; c = 0; // 現在のy位置を算出 for (i=0; i<RO_Y_CNT; i++) { if (reg.y >= roady[i] && reg.y < roady[i]+sp2->h+4) { break; } c = i; } _y = i; if(!(roads[_y][_x] & 0x0f)) { cond = RO_GAMEOVER; } else { // あれば再生 if(now.x != _x || now.y != _y) { PlaySoundMem(roads_se[_y][_x] , DX_PLAYTYPE_BACK); } } now.x = _x; now.y = _y; }
void music_play(){ int i; for(i=0;i<SE_MAX;i++){ if(se_flag[i]==1) { PlaySoundMem(se_handle[i],DX_PLAYTYPE_BACK); } } bgm_play(); }
void StartScene::select(map<pair<int, int>, string> maps){ if(Keyboard::pushed(KEY_INPUT_DOWN)){ PlaySoundMem(Sound::select, DX_PLAYTYPE_BACK); if(maps == menus[1]){ order[order.size()-1] = (order[order.size()-1] + 1) % (my_mission[0]+1); } else { order[order.size()-1] = (order[order.size()-1] + 1) % maps.size(); } } if(Keyboard::pushed(KEY_INPUT_UP)){ PlaySoundMem(Sound::select, DX_PLAYTYPE_BACK); if(maps == menus[1]){ order[order.size()-1] = (order[order.size()-1] + (my_mission[0])) % (my_mission[0]+1); } else { order[order.size()-1] = (order[order.size()-1] + (maps.size()-1)) % maps.size(); } } }
/* ================================================ */ void SoundManager::PlaySE(const char *tagSE, const uint32_t &volume ) { const uint32_t handle = GetHandleId(tagSE); if(handle == INVALID_VALUE){ DEBUG_PRINT("【再生しようとしたSEはロードされていない?】\n"); return; } SetVolumeSoundMem( volume, handle); PlaySoundMem(GetHandleId(tagSE), DX_PLAYTYPE_BACK); }
void Character::SetLife( int life){ if(damaged_flag == false && muteki == 0) { PlaySoundMem(damage_sound, DX_PLAYTYPE_BACK); this->life = life; damaged_flag = true; } }
void Player::Shift(const bool isUP) { if (isUP) { s_powlv++; // 弾レベルを1段階パワーアップ if (s_powlv != 1) { s_rensha = 1 + (2 * s_powlv); // シフトアップボーナス4メモリ PlaySoundMem(hs_shiftUp, DX_PLAYTYPE_BACK); } } else { s_powlv--; s_rensha = MAX_RENSHA - 4; if (s_powlv == 0) s_rensha = 0; if(s_powlv != 0) PlaySoundMem(hs_shiftDown, DX_PLAYTYPE_BACK); } s_powlv = std::min(MaxPowLevel, std::max(0, s_powlv)); // レベルを基底の範囲内にする // effector->Shift(isUP, s_powlv); // シフトレベルに応じた演出を開始 }
int BmsPlayer::play_channel_sound(int channel, unsigned long long time){ std::pair<int, int> channel_data = ret_channel_array(channel, index_count.at(channel)); if (channel_data.second <= time && channel_data.first != 0){ PlaySoundMem(sound_handle.at(channel_data.first), DX_PLAYTYPE_BACK); index_count.at(channel)++; return 1; } return 0; }
void MusicApple::UpDate() { if(sqrt(pow(((double)mousex-x), 2)+pow(((double)mousey-y), 2)) <= hit_area){ if(!once){ PlaySoundMem(sound_h_demo, DX_PLAYTYPE_LOOP); once = true; } }else{ once = false; StopSoundMem(sound_h_demo); } }
void StartScene::initialize(){ FileStream::load("data/data.dat", my_mission); if(my_mission.empty()){ my_mission.push_back(0); my_mission.push_back(0); FileStream::write("data/data.dat", my_mission); } if(my_mission[0] <= 0) order.push_back(0); else order.push_back(1); PlaySoundMem(Sound::start_scene, DX_PLAYTYPE_LOOP); }
void music_play(){ int i; for(i=0;i<SE_MAX;i++){ if(se_flag[i]==1){ if(CheckSoundMem(sound_se[i])!=0){ if(i==8)continue; StopSoundMem(sound_se[i]); } PlaySoundMem(sound_se[i],DX_PLAYTYPE_BACK); } } }
//bgmのメイン処理 void bgm_main() { if(area[stage].bgm.flag==0) {//最初に読み込む load_bgm(0); SetLoopPosSoundMem(area[stage].bgm.loop_pos[0], area[stage].bgm.handle);//ループ一セット area[stage].bgm.flag=1; } if(area[stage].bgm.flag==1) {//種類に応じて再生を始める switch(area[stage].bgm.knd[0]) { case 0://再生種類0なら if(stage_count==60) {//始まって60カウント後に再生 PlaySoundMem(area[stage].bgm.handle, DX_PLAYTYPE_LOOP); area[stage].bgm.flag=2; } break; default: break; } } if(area[stage].bgm.flag==2) {//ボス出現時に読み込む if(stage_count==boss_load[stage].cnt) {//ボスが現れたら読み込む StopSoundMem(area[stage].bgm.handle); delete_bgm(); load_bgm(1); SetLoopPosSoundMem(area[stage].bgm.loop_pos[1], area[stage].bgm.handle);//ループ一セット area[stage].bgm.flag=3; } } if(area[stage].bgm.flag==3) { switch(area[stage].bgm.knd[0]) { case 0://再生種類0なら if(stage_count==boss_load[stage].cnt) {//ボスが現れたら再生 PlaySoundMem(area[stage].bgm.handle, DX_PLAYTYPE_LOOP); area[stage].bgm.flag=4; } break; default: break; } } }
void Menu::Update() { title->Update(); // タイトルロゴ if (!title->isStop) return; // 止まっていなければここはスルー const bool INPUT_VERTICAL = ( Keyboard_Get(KEY_INPUT_DOWN) == 1 || Keyboard_Get(KEY_INPUT_UP) == 1 ); const bool INPUT_OK = ( Keyboard_Get(KEY_INPUT_Z) == 1 || Keyboard_Get(KEY_INPUT_RETURN) == 1 ); const bool PUSH_KEY_UP = ( Keyboard_Get(KEY_INPUT_UP) == 1 ); const bool PUSH_KEY_DOWN = ( Keyboard_Get(KEY_INPUT_DOWN) == 1 ); const bool STATE_START = selectNum == 0; const bool STATE_QUIT = selectNum == 3; y_cur = y[selectNum] - 2; // カーソルの位置 if (INPUT_VERTICAL) PlaySoundMem(hs_move, DX_PLAYTYPE_BACK); // ♪カーソル音 if (PUSH_KEY_UP) selectNum = (selectNum + 3) % ALL_SELECT_NUM; // カーソルの移動と選択項目 if (PUSH_KEY_DOWN) selectNum = (selectNum + 1) % ALL_SELECT_NUM; if(INPUT_OK) // 決定キーを押したなら { if (STATE_START) { PlaySoundMem(hs_choice, DX_PLAYTYPE_BACK); // ♪決定音 isGame = true; } if (STATE_QUIT) QuitGame(); // ゲームをやめる } if(isGame) { c_game->Update(); if (c_game->isLast()) mSceneChanger->ChangeScene(eScene_Game); } score->Update(); // スコアデータ更新 AnotherUpdate(); // It's a secret. }
void StartScene::action(){ if(Keyboard::pushed(KEY_INPUT_Z)){ switch(order.size()-1){ case 0: switch(order[order.size()-1]){ case 0: PlaySoundMem(Sound::decide, DX_PLAYTYPE_BACK); SetDrawBlendMode(DX_BLENDMODE_ALPHA, 128); DrawString(5, DEFAULT_SCREEN_SIZE_Y-20, "Now Loading...", GetColor(255,255,255)); changeScene(new BattleScene); break; case 1: if(my_mission[0] > 0){ PlaySoundMem(Sound::step, DX_PLAYTYPE_BACK); order.push_back(0); } break; default: PlaySoundMem(Sound::step, DX_PLAYTYPE_BACK); changeScene(nullptr); break; } break; case 1: PlaySoundMem(Sound::decide, DX_PLAYTYPE_BACK); SetDrawBlendMode(DX_BLENDMODE_ALPHA, 128); DrawString(5, DEFAULT_SCREEN_SIZE_Y-20, "Now Loading...", GetColor(255,255,255)); changeScene(new BattleScene); break; } } if(Keyboard::pushed(KEY_INPUT_X) && order.size() >= 2){ PlaySoundMem(Sound::cancel, DX_PLAYTYPE_BACK); order.pop_back(); } }
//背景 void wall() { if(level == level_wall) { if(change_wall == (timescore + shot_kaisuu)%19) { timescore++; } change_wall = (timescore + shot_kaisuu)%19; level_wall += 3; PlaySoundMem(se_change_wall,DX_PLAYTYPE_BACK); } DrawGraph(0,0,g_w[change_wall],false); }
void bgm_play() { int i; if (bgm_state==0) { for (i=0;i<BGM_MAX;i++) { if (CheckSoundMem(bgm_handle[i])==1) StopSoundMem(bgm_handle[i]) ; } } else if (bgm_state==1) { for (i=0;i<BGM_MAX;i++) { if (CheckSoundMem(bgm_handle[i])==1) StopSoundMem(bgm_handle[i]) ; } PlaySoundMem( bgm_handle[bgm_num] , DX_PLAYTYPE_LOOP ) ; bgm_state++; } else { bgm_state++; } }
int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow ) { int test1; if(DxLib_Init() == -1) return -1; BGM = LoadSoundMem("kbc.wav"); test1 = PlaySoundMem(BGM,DX_PLAYTYPE_NORMAL); while(ProcessMessage() != -1 && CheckHitKeyAll() == 0 ){ if(test1 == -1)LoadGraphScreen( BGM , 0 , "0120.bmp" , true); if(BGM == -1)LoadGraphScreen( BGM , 100 , "0120.bmp" , true); } DxLib_End() ; return 0; }