今回は、(音楽データの問題は後半に回すとして)ゲームオーバー画面の仮実装している最中に起こったバグについて尋ねたいです。
以下、ソースファイル
[hr]↓main.cpp
//前略
switch(func_state){
case 0://初回のみ入る処理
loading();
load(); //データロード
func_state=10;
break;
case 10://初期化処理
loading();
first_ini();//初回の初期化
score_ini();//ハイスコアの読み込み
PlaySoundMem(music[0],DX_PLAYTYPE_BACK);
func_state=20;
break;
case 19:
loading();
delete_bgm();
ini();
func_state=20;
break;
case 20://メニュー画面処理
GAME_TITLE();
break;
case 99://STGを始める前に行う初期化
loading();
ini();
load_story();
func_state=100;
break;
case 100://通常処理
//enter_func_tm("最初");
calc_ch(); //enter_func_tm("キャラ計算");
ch_move(); //enter_func_tm("キャラ移動");
cshot_main(); //enter_func_tm("自機ショットメイン");
enemy_main(); //enter_func_tm("敵処理メイン");
boss_shot_main();//enter_func_tm("ボスショットメイン");
shot_main(); //enter_func_tm("ショットメイン");
out_main(); //enter_func_tm("当たり判定");
effect_main(); //enter_func_tm("エフェクトメイン");
calc_main(); //enter_func_tm("計算メイン");
graph_main(); //enter_func_tm("描画メイン");
bgm_main(); //enter_func_tm("BGMメイン");
if(boss.flag==0) stage_count++;
if(CheckStateKey(KEY_INPUT_P)==1) func_state=101;//Pキーで簡易型ポーズの実装
if(ch.num<0){
func_state=102;
}
if(stage_count>stage_end_time[stage]) func_state=103;
break;
case 101://仮実装のポーズ画面処理
pause();
break;
case 102://仮実装のゲームオーバー画面操作
continue_game();
break;
case 103://仮実装のステージ移行操作
stage_count=0;
stage++;
func_state=100;
break;
case 999://終了前のファイル出力。増やす可能性大
hiscore_write();
func_state=1000;
break;
default:
printfDx("不明なfunc_state\n");
break;
}
//後略
void continue_game(){
//shotキーはKey[4],bomキーはKey[5]に対応している
static int over_state;
switch(over_state){
case 0:
DrawFormatString( 150, 200, color[0], "Game Over!!" );
if(Key[4]==1) over_state=1;
break;
case 1:
if(ch.credit>0){
DrawFormatString( 150, 250, color[0], "continue? credit=%d",ch.credit);
DrawFormatString( 150, 265, color[0], "Yes>>shot No>>bom" );
if(Key[4]==1){
ch.score=0;
ch.num=3;
ch.score++;
ch.credit--;
func_state=100;
over_state=0;
}
if(Key[5]==1){
func_state=19;
over_state=0;
}
}
else{
WaitKey();
func_state=19;
}
break;
default:
printfDx("不明なover_func");
break;
}
}
途中でやめるなどの操作ができません。
自分での考察として、
①func_stateの値の変化のさせ方が不相応
②continue_game関数内のif文の制御の方法が不相応
③over_stateの値の変化のさせ方が不相応
と考えております。
自分でも何度も考えてみましたが、わかりません。
また凡ミスをしている可能性もあるので、再度チェックを重ねるつもりですが、どうかよろしくお願いします。