とりあえず、『音を出してそれぞれの状態へ遷移する』という処理は
大体こんな感じでよいのではないでしょうか。
(一部 適当な部分アリ)
音の部分はコメントアウトしてるので、任意のファイル名にして
コメントアウトを外すと動くと思います。
---------------------------------------------------------------------------------------
#include "DxLib.h"
int Key[256];
int kettei1 ;
int GetHitKeyStateAll_2(int KeyStateBuf[/url]){
char GetHitKeyStateAll_Key[256];
GetHitKeyStateAll( GetHitKeyStateAll_Key );
for(int i=0;i<256;i++){
if(GetHitKeyStateAll_Key==1) KeyStateBuf++;
else KeyStateBuf=0;
}
return 0;
}
enum SeqID{
SEQ_TITLE,
SEQ_NEW_GAME,
SEQ_CONTINUE,
SEQ_OPTION,
SEQ_EXIT
};
SeqID NowSeq = SEQ_TITLE;
typedef struct{
POINT pt;
char* msg;
SeqID next;
}A;
A mozi[/url] = {{100,20,"NewGame",SEQ_NEW_GAME},
{100,40,"Continue",SEQ_CONTINUE},
{100,60,"Option",SEQ_OPTION},
{100,80,"Exit",SEQ_EXIT}};
void Title(void)
{
int White = GetColor( 255 , 255 , 255 ) ; // 白色の値を取得
int Yellow = GetColor( 255 , 255 , 0 ) ; // 黄色の値を取得
int Cyan = GetColor( 0 , 255 , 255 ) ; // 水色の値を取得
int TempColor = 0;
static int Cursor = 0;
int count = sizeof(mozi) / sizeof(mozi[0]);
//カーソルの移動
if(Key[KEY_INPUT_DOWN] == 1 || (Key[KEY_INPUT_DOWN] > 20 && Key[KEY_INPUT_DOWN] % 10 == 0))
Cursor = (Cursor + 1) % count;
else if(Key[KEY_INPUT_UP] == 1 || (Key[KEY_INPUT_UP] > 20 && Key[KEY_INPUT_UP] % 10 == 0))
Cursor = (Cursor + count - 1) % count;
//選択肢の表示
for(int i = 0; i < count; i++){
if(i == Cursor)TempColor = Cyan;
else TempColor = White;
DrawString( mozi.pt.x, mozi.pt.y, mozi.msg , TempColor);
}
//カーソルの表示
DrawString( mozi[Curso[/url].pt.x - 20, mozi[Curso[/url].pt.y, "⇒" , Yellow);
//遷移先決定
if(Key[KEY_INPUT_RETURN] == 1){
//PlaySoundMem( kettei1 , DX_PLAYTYPE_BACK );
NowSeq = mozi[Curso[/url].next;
Cursor = 0;
}
}
void NewGame(void)
{
int White = GetColor( 255 , 255 , 255 ) ; // 白色の値を取得
DrawString( 100, 100, "NewGame画面です。" , White);
}
void Continue(void)
{
int White = GetColor( 255 , 255 , 255 ) ; // 白色の値を取得
DrawString( 100, 100, "Continue画面です。" , White);
}
void Option(void)
{
int White = GetColor( 255 , 255 , 255 ) ; // 白色の値を取得
DrawString( 100, 100, "Option画面です。" , White);
}
int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance,LPSTR lpCmdLine, int nCmdShow ){
ChangeWindowMode( TRUE );
if(DxLib_Init() == -1 ) return -1;
SetDrawScreen( DX_SCREEN_BACK );
//kettei1 = LoadSoundMem( "bgm_config.wav" ) ;
while(ProcessMessage()==0 && ClearDrawScreen()==0 && GetHitKeyStateAll_2(Key)==0 && Key[KEY_INPUT_ESCAPE]==0 && NowSeq != SEQ_EXIT){
switch(NowSeq){
case SEQ_TITLE: Title();
break;
case SEQ_NEW_GAME: NewGame();
break;
case SEQ_CONTINUE: Continue();
break;
case SEQ_OPTION: Option();
break;
default:break;
}
ScreenFlip();
}
DxLib_End();
return 0;
}
---------------------------------------------------------------------------------------